‪TYPO3CMS  10.4
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 
21 
29 {
33  protected ‪$context;
34 
40  public function ‪__construct(‪Context ‪$context = null, int ‪$pageId = null, array $rootLine = null)
41  {
42  $this->context = ‪$context ?? GeneralUtility::makeInstance(Context::class);
43  $this->pageId = ‪$pageId;
44  $this->rootline = $rootLine ?? (array)‪$GLOBALS['TSFE']->tmpl->rootLine;
45  $this->initializeExpressionLanguageResolver();
46  }
47 
48  protected function ‪updateExpressionLanguageVariables(): void
49  {
50  $tree = new \stdClass();
51  $tree->level = $this->rootline ? count($this->rootline) - 1 : 0;
52  $tree->rootLine = ‪$this->rootline;
53  $tree->rootLineIds = array_column($this->rootline, 'uid');
54  $tree->rootLineParentIds = array_slice(array_column($this->rootline, 'pid'), 1);
55 
56  $frontendUserAspect = $this->context->getAspect('frontend.user');
57  $frontend = new \stdClass();
58  $frontend->user = new \stdClass();
59  $frontend->user->isLoggedIn = $frontendUserAspect->get('isLoggedIn');
60  $frontend->user->userId = $frontendUserAspect->get('id');
61  $frontend->user->userGroupList = implode(',', $frontendUserAspect->get('groupIds'));
62 
63  $backendUserAspect = $this->context->getAspect('backend.user');
64  $backend = new \stdClass();
65  $backend->user = new \stdClass();
66  $backend->user->isAdmin = $backendUserAspect->get('isAdmin');
67  $backend->user->isLoggedIn = $backendUserAspect->get('isLoggedIn');
68  $backend->user->userId = $backendUserAspect->get('id');
69  $backend->user->userGroupList = implode(',', $backendUserAspect->get('groupIds'));
70 
71  $workspaceAspect = $this->context->getAspect('workspace');
72  $workspace = new \stdClass();
73  $workspace->workspaceId = $workspaceAspect->get('id');
74  $workspace->isLive = $workspaceAspect->get('isLive');
75  $workspace->isOffline = $workspaceAspect->get('isOffline');
76 
77  $this->expressionLanguageResolverVariables = [
78  'tree' => $tree,
79  'frontend' => $frontend,
80  'backend' => $backend,
81  'workspace' => $workspace,
82  'page' => ‪$GLOBALS['TSFE']->page ?? [],
83  ];
84  }
85 }
‪TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$pageId
‪int $pageId
Definition: AbstractConditionMatcher.php:41
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher
Definition: AbstractConditionMatcher.php:34
‪TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$rootline
‪array $rootline
Definition: AbstractConditionMatcher.php:47
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\updateExpressionLanguageVariables
‪updateExpressionLanguageVariables()
Definition: ConditionMatcher.php:47
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching
Definition: ConditionMatcher.php:16
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\$context
‪Context $context
Definition: ConditionMatcher.php:32
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher
Definition: ConditionMatcher.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\__construct
‪__construct(Context $context=null, int $pageId=null, array $rootLine=null)
Definition: ConditionMatcher.php:39
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46