‪TYPO3CMS  10.4
AbstractModule.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 
25 
31 {
32 
36  protected ‪$subModules = [];
37 
43  protected ‪$mainConfiguration;
44 
48  protected ‪$configurationService;
49 
50  public function ‪__construct()
51  {
52  $this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
53  $this->mainConfiguration = $this->configurationService->getMainConfiguration();
54  }
55 
65  public function ‪isEnabled(): bool
66  {
67  $identifier = $this->‪getIdentifier();
68  $result = $this->‪isEnabledViaTsConfig();
69  if ($this->mainConfiguration['override.'][$identifier] ?? false) {
70  $result = (bool)$this->mainConfiguration['override.'][$identifier];
71  }
72  return $result;
73  }
74 
78  public function ‪setSubModules(array ‪$subModules): void
79  {
80  $this->subModules = ‪$subModules;
81  }
82 
86  public function ‪getSubModules(): array
87  {
88  return ‪$this->subModules;
89  }
90 
94  public function ‪hasSubmoduleSettings(): bool
95  {
96  $hasSettings = false;
97  foreach ($this->subModules as $subModule) {
98  if ($subModule instanceof ‪ModuleSettingsProviderInterface) {
99  $hasSettings = true;
100  break;
101  }
102  if ($subModule instanceof ‪SubmoduleProviderInterface) {
103  $hasSettings = $subModule->hasSubmoduleSettings();
104  }
105  }
106  return $hasSettings;
107  }
108 
114  protected function ‪getBackendUser(): ‪BackendUserAuthentication
115  {
116  return ‪$GLOBALS['BE_USER'];
117  }
118 
124  protected function ‪getLanguageService(): ‪LanguageService
125  {
126  return ‪$GLOBALS['LANG'];
127  }
128 
134  protected function ‪isEnabledViaTsConfig(): bool
135  {
136  $result = false;
137  $identifier = $this->‪getIdentifier();
138  if (!empty($this->mainConfiguration['enable.']['all'])) {
139  $result = true;
140  } elseif (!empty($this->mainConfiguration['enable.'][$identifier])) {
141  $result = true;
142  }
143  return $result;
144  }
145 }
‪TYPO3\CMS\Adminpanel\ModuleApi
Definition: AbstractModule.php:18
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule
Definition: AbstractModule.php:31
‪TYPO3\CMS\Backend\FrontendBackendUserAuthentication
Definition: FrontendBackendUserAuthentication.php:31
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\isEnabled
‪bool isEnabled()
Definition: AbstractModule.php:62
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\isEnabledViaTsConfig
‪bool isEnabledViaTsConfig()
Definition: AbstractModule.php:131
‪TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface
Definition: ConfigurableInterface.php:29
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$mainConfiguration
‪array $mainConfiguration
Definition: AbstractModule.php:41
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$subModules
‪ModuleInterface[] $subModules
Definition: AbstractModule.php:35
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleSettingsProviderInterface
Definition: ModuleSettingsProviderInterface.php:34
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getSubModules
‪getSubModules()
Definition: AbstractModule.php:83
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\hasSubmoduleSettings
‪hasSubmoduleSettings()
Definition: AbstractModule.php:91
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$configurationService
‪ConfigurationService $configurationService
Definition: AbstractModule.php:45
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\__construct
‪__construct()
Definition: AbstractModule.php:47
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:34
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\setSubModules
‪setSubModules(array $subModules)
Definition: AbstractModule.php:75
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface
Definition: ModuleInterface.php:26
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractModule.php:121
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface\getIdentifier
‪string getIdentifier()
‪TYPO3\CMS\Adminpanel\ModuleApi\SubmoduleProviderInterface
Definition: SubmoduleProviderInterface.php:30
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: AbstractModule.php:111