getDocumentParserContext()->getParser(); $parserContext = $parser->getParserContext(); $path = $parserContext->absoluteRelativePath($directive->getData()); $origin = $parserContext->getOrigin(); if (!$origin->has($path)) { throw new RuntimeException( sprintf('Include "%s" (%s) does not exist or is not readable.', $directive->getData(), $path), ); } $contents = $origin->read($path); if ($contents === false) { throw new RuntimeException(sprintf('Could not load file from path %s', $path)); } $codeNode = new CodeNode(explode("\n", $contents)); $this->codeNodeOptionMapper->apply($codeNode, $directive->getOptions(), $blockContext); return $codeNode; } }