‪TYPO3CMS  ‪main
UserTsConfigFactory.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 
38 {
39  public function ‪__construct(
40  private readonly ContainerInterface $container,
41  private readonly ‪TokenizerInterface $tokenizer,
42  private readonly ‪TsConfigTreeBuilder $tsConfigTreeBuilder,
43  private readonly ‪PhpFrontend $cache,
44  ) {}
45 
47  {
48  $includeTreeTraverserConditionVerdictAware = new ‪ConditionVerdictAwareIncludeTreeTraverser();
49  $includeTreeTraverserConditionVerdictAwareVisitors = [];
50  $userTsConfigTree = $this->tsConfigTreeBuilder->getUserTsConfigTree($backendUser, $this->tokenizer, $this->cache);
51  $conditionMatcherVisitor = GeneralUtility::makeInstance(IncludeTreeConditionMatcherVisitor::class);
52  // User TSconfig is not within page context, that what page TSconfig is for, so 'page', 'pageId',
53  // 'rootLine' and 'tree' can not be used in user TSconfig conditions. There is no request, either.
54  $conditionMatcherVisitor->initializeExpressionMatcherWithVariables([
55  'page' => [],
56  'pageId' => 0,
57  ]);
58  $includeTreeTraverserConditionVerdictAwareVisitors[] = $conditionMatcherVisitor;
59  $astBuilderVisitor = $this->container->get(IncludeTreeAstBuilderVisitor::class);
60  $includeTreeTraverserConditionVerdictAwareVisitors[] = $astBuilderVisitor;
61  $includeTreeTraverserConditionVerdictAware->traverse($userTsConfigTree, $includeTreeTraverserConditionVerdictAwareVisitors);
62  return new ‪UserTsConfig($astBuilderVisitor->getAst());
63  }
64 }
‪TYPO3\CMS\Core\TypoScript\UserTsConfigFactory\__construct
‪__construct(private readonly ContainerInterface $container, private readonly TokenizerInterface $tokenizer, private readonly TsConfigTreeBuilder $tsConfigTreeBuilder, private readonly PhpFrontend $cache,)
Definition: UserTsConfigFactory.php:39
‪TYPO3\CMS\Core\TypoScript\UserTsConfig
Definition: UserTsConfig.php:28
‪TYPO3\CMS\Core\TypoScript\UserTsConfigFactory\create
‪create(BackendUserAuthentication $backendUser)
Definition: UserTsConfigFactory.php:46
‪TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
Definition: PhpFrontend.php:25
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeAstBuilderVisitor
Definition: IncludeTreeAstBuilderVisitor.php:39
‪TYPO3\CMS\Core\TypoScript
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\TypoScript\UserTsConfigFactory
Definition: UserTsConfigFactory.php:38
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\ConditionVerdictAwareIncludeTreeTraverser
Definition: ConditionVerdictAwareIncludeTreeTraverser.php:38
‪TYPO3\CMS\Core\TypoScript\Tokenizer\TokenizerInterface
Definition: TokenizerInterface.php:40
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\TypoScript\IncludeTree\TsConfigTreeBuilder
Definition: TsConfigTreeBuilder.php:44
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionMatcherVisitor
Definition: IncludeTreeConditionMatcherVisitor.php:44