‪TYPO3CMS  ‪main
IncludeTreeConditionEnforcerVisitor.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 
22 
32 {
36  private array ‪$enabledConditions;
37 
38  public function ‪setEnabledConditions(array ‪$enabledConditions): void
39  {
40  $this->enabledConditions = ‪$enabledConditions;
41  }
42 
43  public function ‪visitBeforeChildren(‪IncludeInterface $include, int $currentDepth): void
44  {
45  if (!$include instanceof ‪IncludeConditionInterface) {
46  return;
47  }
48  $conditionValue = $include->getConditionToken()->getValue();
49  if (in_array($conditionValue, $this->enabledConditions) && !$include->isConditionNegated()
50  || !in_array($conditionValue, $this->enabledConditions) && $include->isConditionNegated()
51  ) {
52  $include->setConditionVerdict(true);
53  } else {
54  $include->setConditionVerdict(false);
55  }
56  }
57 
58  public function ‪visit(‪IncludeInterface $include, int $currentDepth): void {}
59 }
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionEnforcerVisitor\visitBeforeChildren
‪visitBeforeChildren(IncludeInterface $include, int $currentDepth)
Definition: IncludeTreeConditionEnforcerVisitor.php:43
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionEnforcerVisitor
Definition: IncludeTreeConditionEnforcerVisitor.php:32
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeVisitorInterface
Definition: IncludeTreeVisitorInterface.php:28
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeConditionInterface
Definition: IncludeConditionInterface.php:32
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface
Definition: IncludeInterface.php:39
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionEnforcerVisitor\visit
‪visit(IncludeInterface $include, int $currentDepth)
Definition: IncludeTreeConditionEnforcerVisitor.php:58
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionEnforcerVisitor\$enabledConditions
‪array $enabledConditions
Definition: IncludeTreeConditionEnforcerVisitor.php:36
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor
Definition: IncludeTreeAstBuilderVisitor.php:18
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionEnforcerVisitor\setEnabledConditions
‪setEnabledConditions(array $enabledConditions)
Definition: IncludeTreeConditionEnforcerVisitor.php:38