‪TYPO3CMS  ‪main
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 
23 
29 {
31  protected array ‪$subModules = [];
33  protected array ‪$mainConfiguration;
36 
38  {
39  $this->configurationService = ‪$configurationService;
40  $this->mainConfiguration = $this->configurationService->‪getMainConfiguration();
41  }
42 
50  public function ‪isEnabled(): bool
51  {
53  $result = $this->‪isEnabledViaTsConfig();
54  if ($this->mainConfiguration['override.'][‪$identifier] ?? false) {
55  $result = (bool)$this->mainConfiguration['override.'][‪$identifier];
56  }
57  return $result;
58  }
59 
60  public function ‪setSubModules(array ‪$subModules): void
61  {
62  $this->subModules = ‪$subModules;
63  }
64 
65  public function ‪getSubModules(): array
66  {
67  return ‪$this->subModules;
68  }
69 
70  public function ‪hasSubmoduleSettings(): bool
71  {
72  $hasSettings = false;
73  foreach ($this->subModules as $subModule) {
74  if ($subModule instanceof ‪ModuleSettingsProviderInterface) {
75  $hasSettings = true;
76  break;
77  }
78  if ($subModule instanceof ‪SubmoduleProviderInterface) {
79  $hasSettings = $subModule->hasSubmoduleSettings();
80  }
81  }
82  return $hasSettings;
83  }
84 
86  {
87  $this->moduleData = ‪$moduleData;
88  }
89 
91  {
92  return ‪$GLOBALS['BE_USER'];
93  }
94 
96  {
97  return ‪$GLOBALS['LANG'];
98  }
99 
103  protected function ‪isEnabledViaTsConfig(): bool
104  {
105  $result = false;
106  ‪$identifier = $this->‪getIdentifier();
107  if (!empty($this->mainConfiguration['enable.']['all'])) {
108  $result = true;
109  } elseif (!empty($this->mainConfiguration['enable.'][‪$identifier])) {
110  $result = true;
111  }
112  return $result;
113  }
114 }
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleDataStorageCollection
Definition: ModuleDataStorageCollection.php:24
‪TYPO3\CMS\Adminpanel\ModuleApi
Definition: AbstractModule.php:18
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule
Definition: AbstractModule.php:29
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getBackendUser
‪getBackendUser()
Definition: AbstractModule.php:90
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\isEnabled
‪isEnabled()
Definition: AbstractModule.php:50
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$subModules
‪array $subModules
Definition: AbstractModule.php:31
‪TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface
Definition: ConfigurableInterface.php:29
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getLanguageService
‪getLanguageService()
Definition: AbstractModule.php:95
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$mainConfiguration
‪array $mainConfiguration
Definition: AbstractModule.php:33
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\injectConfigurationService
‪injectConfigurationService(ConfigurationService $configurationService)
Definition: AbstractModule.php:37
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleSettingsProviderInterface
Definition: ModuleSettingsProviderInterface.php:34
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\getMainConfiguration
‪getMainConfiguration()
Definition: ConfigurationService.php:38
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getSubModules
‪getSubModules()
Definition: AbstractModule.php:65
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface\getIdentifier
‪getIdentifier()
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\hasSubmoduleSettings
‪hasSubmoduleSettings()
Definition: AbstractModule.php:70
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\isEnabledViaTsConfig
‪isEnabledViaTsConfig()
Definition: AbstractModule.php:103
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$configurationService
‪ConfigurationService $configurationService
Definition: AbstractModule.php:34
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:34
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\$moduleData
‪ModuleDataStorageCollection $moduleData
Definition: AbstractModule.php:35
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\setSubModules
‪setSubModules(array $subModules)
Definition: AbstractModule.php:60
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface
Definition: ModuleInterface.php:26
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\setModuleData
‪setModuleData(ModuleDataStorageCollection $moduleData)
Definition: AbstractModule.php:85
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Adminpanel\ModuleApi\SubmoduleProviderInterface
Definition: SubmoduleProviderInterface.php:30
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37