/** * 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.ts2`'); }
/** * 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 = 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); }
/** * Returns a merged TypoScript object tree in the context of the given nodes * * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $startNode Node marking the starting point * @return array The merged object tree as of the given node * @throws \TYPO3\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); }
/** * Returns a merged TypoScript object tree loaded from a specified resource location. * * @param string $typoScriptResourcePath * @return array The merged object tree as of the given node */ public function readTypoScriptFromSpecificPath($typoScriptResourcePath) { $mergedTypoScriptCode = $this->readExternalTypoScriptFiles($typoScriptResourcePath) . chr(10); return $this->typoScriptParser->parse($mergedTypoScriptCode); }