‪TYPO3CMS  9.5
AbstractModule.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
24 
30 {
31 
35  protected ‪$subModules = [];
36 
42  protected ‪$mainConfiguration;
43 
47  protected ‪$configurationService;
48 
49  public function ‪__construct()
50  {
51  $this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
52  $this->mainConfiguration = $this->configurationService->getMainConfiguration();
53  }
54 
64  public function ‪isEnabled(): bool
65  {
66  $identifier = $this->‪getIdentifier();
67  $result = $this->‪isEnabledViaTsConfig();
68  if ($this->mainConfiguration['override.'][$identifier] ?? false) {
69  $result = (bool)$this->mainConfiguration['override.'][$identifier];
70  }
71  return $result;
72  }
73 
77  public function ‪setSubModules(array ‪$subModules): void
78  {
79  $this->subModules = ‪$subModules;
80  }
81 
85  public function ‪getSubModules(): array
86  {
87  return ‪$this->subModules;
88  }
89 
93  public function ‪hasSubmoduleSettings(): bool
94  {
95  $hasSettings = false;
96  foreach ($this->subModules as $subModule) {
97  if ($subModule instanceof ‪ModuleSettingsProviderInterface) {
98  $hasSettings = true;
99  break;
100  }
101  if ($subModule instanceof ‪SubmoduleProviderInterface) {
102  $hasSettings = $subModule->hasSubmoduleSettings();
103  }
104  }
105  return $hasSettings;
106  }
107 
113  protected function ‪getBackendUser(): ‪BackendUserAuthentication
114  {
115  return ‪$GLOBALS['BE_USER'];
116  }
117 
123  protected function ‪getLanguageService(): ‪LanguageService
124  {
125  return ‪$GLOBALS['LANG'];
126  }
127 
133  protected function ‪isEnabledViaTsConfig(): bool
134  {
135  $result = false;
136  $identifier = $this->‪getIdentifier();
137  if (!empty($this->mainConfiguration['enable.']['all'])) {
138  $result = true;
139  } elseif (!empty($this->mainConfiguration['enable.'][$identifier])) {
140  $result = true;
141  }
142  return $result;
143  }
144 }
‪TYPO3\CMS\Adminpanel\ModuleApi
Definition: AbstractModule.php:4
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule
Definition: AbstractModule.php:30
‪TYPO3\CMS\Backend\FrontendBackendUserAuthentication
Definition: FrontendBackendUserAuthentication.php:35
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\isEnabled
‪bool isEnabled()
Definition: AbstractModule.php:61
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\isEnabledViaTsConfig
‪bool isEnabledViaTsConfig()
Definition: AbstractModule.php:130
‪TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface
Definition: ConfigurableInterface.php:28
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$mainConfiguration
‪array $mainConfiguration
Definition: AbstractModule.php:40
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$subModules
‪ModuleInterface[] $subModules
Definition: AbstractModule.php:34
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleSettingsProviderInterface
Definition: ModuleSettingsProviderInterface.php:33
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getSubModules
‪getSubModules()
Definition: AbstractModule.php:82
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\hasSubmoduleSettings
‪hasSubmoduleSettings()
Definition: AbstractModule.php:90
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$configurationService
‪ConfigurationService $configurationService
Definition: AbstractModule.php:44
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\__construct
‪__construct()
Definition: AbstractModule.php:46
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:33
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\setSubModules
‪setSubModules(array $subModules)
Definition: AbstractModule.php:74
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface
Definition: ModuleInterface.php:25
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractModule.php:120
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface\getIdentifier
‪string getIdentifier()
‪TYPO3\CMS\Adminpanel\ModuleApi\SubmoduleProviderInterface
Definition: SubmoduleProviderInterface.php:29
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: AbstractModule.php:110