‪TYPO3CMS  11.5
ConditionMatcher.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
30 {
34  protected ‪$context;
35 
42  protected array ‪$fullRootLine;
43 
50  public function ‪__construct(?‪Context ‪$context = null, ?int ‪$pageId = null, ?array $rootLine = null, ?array ‪$fullRootLine = null)
51  {
52  $this->context = ‪$context ?? GeneralUtility::makeInstance(Context::class);
53  $this->pageId = ‪$pageId;
54  $this->rootline = $rootLine ?? ‪$GLOBALS['TSFE']->tmpl->rootLine ?? [];
55  $this->fullRootLine = ‪$fullRootLine ?? ‪$GLOBALS['TSFE']->rootLine ?? [];
57  }
58 
59  protected function ‪updateExpressionLanguageVariables(): void
60  {
61  $page = ‪$GLOBALS['TSFE']->page ?? [];
62 
63  $tree = new \stdClass();
64  $tree->level = $this->rootline ? count($this->rootline) - 1 : 0;
65  $tree->rootLine = ‪$this->rootline;
66  $tree->rootLineIds = array_column($this->rootline, 'uid');
67  $tree->rootLineParentIds = array_slice(array_column($this->rootline, 'pid'), 1);
68  // We're feeding the "full" RootLine here, not the "local" one that stops at sys_template record having 'root' set.
69  // This is to be in-line with backend here: A 'backend_layout_next_level' on a page above sys_template 'root' page should
70  // still be considered. Additionally, $this->fullRootLine is "deepest page first, then up" for getLayoutForPage() to find
71  // the 'nearest' parent.
72  $tree->pagelayout = GeneralUtility::makeInstance(PageLayoutResolver::class)->getLayoutForPage($page, $this->fullRootLine);
73 
74  $frontendUserAspect = $this->context->getAspect('frontend.user');
75  $frontend = new \stdClass();
76  $frontend->user = new \stdClass();
77  $frontend->user->isLoggedIn = $frontendUserAspect->get('isLoggedIn');
78  $frontend->user->userId = $frontendUserAspect->get('id');
79  $frontend->user->userGroupList = implode(',', $frontendUserAspect->get('groupIds'));
80  $frontend->user->userGroupIds = $frontendUserAspect->get('groupIds');
81 
82  $backendUserAspect = $this->context->getAspect('backend.user');
83  $backend = new \stdClass();
84  $backend->user = new \stdClass();
85  $backend->user->isAdmin = $backendUserAspect->get('isAdmin');
86  $backend->user->isLoggedIn = $backendUserAspect->get('isLoggedIn');
87  $backend->user->userId = $backendUserAspect->get('id');
88  $backend->user->userGroupList = implode(',', $backendUserAspect->get('groupIds'));
89  $backend->user->userGroupIds = $backendUserAspect->get('groupIds');
90 
91  $workspaceAspect = $this->context->getAspect('workspace');
92  $workspace = new \stdClass();
93  $workspace->workspaceId = $workspaceAspect->get('id');
94  $workspace->isLive = $workspaceAspect->get('isLive');
95  $workspace->isOffline = $workspaceAspect->get('isOffline');
96 
97  $this->expressionLanguageResolverVariables = [
98  'tree' => $tree,
99  'frontend' => $frontend,
100  'backend' => $backend,
101  'workspace' => $workspace,
102  'page' => $page,
103  ];
104  }
105 }
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\$fullRootLine
‪array $fullRootLine
Definition: ConditionMatcher.php:41
‪TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$pageId
‪int $pageId
Definition: AbstractConditionMatcher.php:43
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher
Definition: AbstractConditionMatcher.php:36
‪TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$rootline
‪array $rootline
Definition: AbstractConditionMatcher.php:49
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\updateExpressionLanguageVariables
‪updateExpressionLanguageVariables()
Definition: ConditionMatcher.php:58
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching
Definition: ConditionMatcher.php:16
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\$context
‪Context $context
Definition: ConditionMatcher.php:33
‪TYPO3\CMS\Frontend\Page\PageLayoutResolver
Definition: PageLayoutResolver.php:32
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher
Definition: ConditionMatcher.php:30
‪TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\initializeExpressionLanguageResolver
‪initializeExpressionLanguageResolver()
Definition: AbstractConditionMatcher.php:73
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\__construct
‪__construct(?Context $context=null, ?int $pageId=null, ?array $rootLine=null, ?array $fullRootLine=null)
Definition: ConditionMatcher.php:49