‪TYPO3CMS  ‪main
IncludeTreeCommentAwareAstBuilderVisitor.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 
24 
41 {
43 
47  private array ‪$flatConstants = [];
48 
49  public function ‪__construct(private readonly ‪CommentAwareAstBuilder $astBuilder)
50  {
51  $this->ast = new ‪RootNode();
52  }
53 
60  public function ‪setFlatConstants(array ‪$flatConstants)
61  {
62  $this->flatConstants = ‪$flatConstants;
63  }
64 
65  public function ‪getAst(): ‪RootNode
66  {
67  return ‪$this->ast;
68  }
69 
70  public function ‪visitBeforeChildren(‪IncludeInterface $include, int $currentDepth): void
71  {
72  if ($include instanceof ‪SysTemplateInclude && $include->‪isClear()) {
73  // Reset any given AST if this sys_template row has clear flag (constants or setup clear) set.
74  $this->ast = new ‪RootNode();
75  }
76  }
77 
78  public function ‪visit(‪IncludeInterface $include, int $currentDepth): void
79  {
80  $tokenStream = $include->‪getLineStream();
81  if ($tokenStream && !$include->‪isSplit()) {
82  $this->ast = $this->astBuilder->build($tokenStream, $this->ast, $this->flatConstants);
83  }
84  }
85 }
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor\visit
‪visit(IncludeInterface $include, int $currentDepth)
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:78
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:41
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor\__construct
‪__construct(private readonly CommentAwareAstBuilder $astBuilder)
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:49
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor\visitBeforeChildren
‪visitBeforeChildren(IncludeInterface $include, int $currentDepth)
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:70
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeVisitorInterface
Definition: IncludeTreeVisitorInterface.php:28
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface
Definition: IncludeInterface.php:39
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor\setFlatConstants
‪setFlatConstants(array $flatConstants)
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:60
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor\$flatConstants
‪array $flatConstants
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:47
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\isSplit
‪isSplit()
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor\$ast
‪RootNode $ast
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:42
‪TYPO3\CMS\Core\TypoScript\AST\Node\RootNode
Definition: RootNode.php:26
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\isClear
‪isClear()
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\getLineStream
‪getLineStream()
‪TYPO3\CMS\Core\TypoScript\AST\CommentAwareAstBuilder
Definition: CommentAwareAstBuilder.php:55
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor\getAst
‪getAst()
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:65
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor
Definition: IncludeTreeAstBuilderVisitor.php:18
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\SysTemplateInclude
Definition: SysTemplateInclude.php:26