‪TYPO3CMS  ‪main
TypoScriptStringFactory.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Container\ContainerInterface;
29 
37 {
38  public function ‪__construct(
39  private readonly ContainerInterface $container,
40  private readonly ‪TokenizerInterface $tokenizer,
41  ) {}
42 
48  public function ‪parseFromStringWithIncludes(string ‪$name, string $typoScript): ‪RootNode
49  {
50  $cacheManager = $this->container->get(CacheManager::class);
52  $cache = $cacheManager->getCache('typoscript');
53  $stringTreeBuilder = $this->container->get(StringTreeBuilder::class);
54  $includeTree = $stringTreeBuilder->getTreeFromString(‪$name, $typoScript, $this->tokenizer, $cache);
55  $includeTreeTraverserConditionVerdictAware = new ‪IncludeTreeTraverser();
56  $astBuilderVisitor = $this->container->get(IncludeTreeAstBuilderVisitor::class);
57  $includeTreeTraverserConditionVerdictAware->traverse($includeTree, [$astBuilderVisitor]);
58  return $astBuilderVisitor->getAst();
59  }
60 
67  public function ‪parseFromString(string $typoScript, ‪AstBuilderInterface $astBuilder): ‪RootNode
68  {
69  $lineStream = $this->tokenizer->tokenize($typoScript);
70  return $astBuilder->‪build($lineStream, new ‪RootNode());
71  }
72 }
‪TYPO3\CMS\Core\TypoScript\TypoScriptStringFactory\__construct
‪__construct(private readonly ContainerInterface $container, private readonly TokenizerInterface $tokenizer,)
Definition: TypoScriptStringFactory.php:38
‪TYPO3\CMS\Core\TypoScript\TypoScriptStringFactory\parseFromStringWithIncludes
‪parseFromStringWithIncludes(string $name, string $typoScript)
Definition: TypoScriptStringFactory.php:48
‪TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
Definition: PhpFrontend.php:25
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\IncludeTreeTraverser
Definition: IncludeTreeTraverser.php:30
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeAstBuilderVisitor
Definition: IncludeTreeAstBuilderVisitor.php:43
‪TYPO3\CMS\Core\TypoScript
‪TYPO3\CMS\Core\TypoScript\IncludeTree\StringTreeBuilder
Definition: StringTreeBuilder.php:38
‪$name
‪$name
Definition: phpIntegrityChecker.php:235
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:36
‪TYPO3\CMS\Core\TypoScript\AST\AstBuilderInterface
Definition: AstBuilderInterface.php:34
‪TYPO3\CMS\Core\TypoScript\AST\AstBuilderInterface\build
‪build(LineStream $lineStream, RootNode $ast, array $flatConstants=[])
‪TYPO3\CMS\Core\TypoScript\TypoScriptStringFactory\parseFromString
‪parseFromString(string $typoScript, AstBuilderInterface $astBuilder)
Definition: TypoScriptStringFactory.php:67
‪TYPO3\CMS\Core\TypoScript\AST\Node\RootNode
Definition: RootNode.php:26
‪TYPO3\CMS\Core\TypoScript\Tokenizer\TokenizerInterface
Definition: TokenizerInterface.php:40
‪TYPO3\CMS\Core\TypoScript\TypoScriptStringFactory
Definition: TypoScriptStringFactory.php:37