Inheritance: implements Neos\Fusion\Core\ParserInterface
 /**
  * Checks if comments in comments are parsed correctly
  *
  * @test
  */
 public function parserCorrectlyParsesComments01()
 {
     $sourceCode = $this->readTypoScriptFixture('ParserTestTypoScriptComments01');
     $expected = array();
     // Fixture contains only comments, so expect empty parse tree
     $actualParseTree = $this->parser->parse($sourceCode);
     $this->assertEquals($expected, $actualParseTree, 'The parse tree was not as expected after parsing fixture `ParserTestTypoScriptComments01.fusion`');
 }
 /**
  * Load TypoScript from the directories specified by $this->getOption('typoScriptPathPatterns')
  *
  * @return void
  */
 protected function loadTypoScript()
 {
     $mergedTypoScriptCode = '';
     $typoScriptPathPatterns = $this->getOption('typoScriptPathPatterns');
     ksort($typoScriptPathPatterns);
     foreach ($typoScriptPathPatterns as $typoScriptPathPattern) {
         $typoScriptPathPattern = str_replace('@package', $this->getPackageKey(), $typoScriptPathPattern);
         $filePaths = array_merge(Files::readDirectoryRecursively($typoScriptPathPattern, '.fusion'), Files::readDirectoryRecursively($typoScriptPathPattern, '.ts2'));
         sort($filePaths);
         foreach ($filePaths as $filePath) {
             $mergedTypoScriptCode .= PHP_EOL . file_get_contents($filePath) . PHP_EOL;
         }
     }
     $this->parsedTypoScript = $this->typoScriptParser->parse($mergedTypoScriptCode);
 }
Example #3
0
 /**
  * Returns a merged TypoScript object tree in the context of the given nodes
  *
  * @param \Neos\ContentRepository\Domain\Model\NodeInterface $startNode Node marking the starting point
  * @return array The merged object tree as of the given node
  * @throws \Neos\Neos\Domain\Exception
  */
 public function getMergedTypoScriptObjectTree(NodeInterface $startNode)
 {
     $contentContext = $startNode->getContext();
     $siteResourcesPackageKey = $contentContext->getCurrentSite()->getSiteResourcesPackageKey();
     $siteRootTypoScriptPathAndFilename = sprintf($this->siteRootTypoScriptPattern, $siteResourcesPackageKey);
     $siteRootTypoScriptCode = $this->readExternalTypoScriptFile($siteRootTypoScriptPathAndFilename);
     if ($siteRootTypoScriptCode === '') {
         $siteRootTypoScriptPathAndFilename = sprintf($this->legacySiteRootTypoScriptPattern, $siteResourcesPackageKey);
         $siteRootTypoScriptCode = $this->readExternalTypoScriptFile($siteRootTypoScriptPathAndFilename);
     }
     $mergedTypoScriptCode = '';
     $mergedTypoScriptCode .= $this->generateNodeTypeDefinitions();
     $mergedTypoScriptCode .= $this->getTypoScriptIncludes($this->prepareAutoIncludeTypoScript());
     $mergedTypoScriptCode .= $this->getTypoScriptIncludes($this->prependTypoScriptIncludes);
     $mergedTypoScriptCode .= $siteRootTypoScriptCode;
     $mergedTypoScriptCode .= $this->getTypoScriptIncludes($this->appendTypoScriptIncludes);
     return $this->typoScriptParser->parse($mergedTypoScriptCode, $siteRootTypoScriptPathAndFilename);
 }