‪TYPO3CMS  11.5
AddonRegistry.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 {
33  protected ‪$registeredAddons = [];
34 
40  public static function ‪getInstance(): ‪AddonRegistry
41  {
42  trigger_error(__CLASS__ . '::getInstance() will be removed in TYPO3 v12.0. Use Dependency Injection or GeneralUtility::makeInstance() if DI is not possible.', E_USER_DEPRECATED);
43  return GeneralUtility::makeInstance(static::class);
44  }
45 
52  public function register(‪Addon $addon): ‪AddonRegistry
53  {
54  $this->registeredAddons[$addon->getIdentifier()] = $addon;
55 
56  return $this;
57  }
58 
63  public function ‪getForMode(string $mode = ''): array
64  {
65  $addons = [];
66 
67  foreach ($this->registeredAddons as $addon) {
68  if (empty($addon->getModes()) || in_array($mode, $addon->getModes(), true)) {
69  $addons[] = $addon;
70  }
71  }
72 
73  return $addons;
74  }
75 
80  public function ‪compileSettings(array $addons): array
81  {
82  $settings = [];
83  foreach ($addons as $addon) {
84  $settings = array_merge($settings, $addon->getOptions());
85  }
86 
87  return $settings;
88  }
89 }
‪TYPO3\CMS\T3editor\Registry\AddonRegistry
Definition: AddonRegistry.php:29
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\$registeredAddons
‪Addon[] $registeredAddons
Definition: AddonRegistry.php:32
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\getInstance
‪static self getInstance()
Definition: AddonRegistry.php:39
‪TYPO3\CMS\T3editor\Addon
Definition: Addon.php:25
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\getForMode
‪Addon[] getForMode(string $mode='')
Definition: AddonRegistry.php:62
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\compileSettings
‪array compileSettings(array $addons)
Definition: AddonRegistry.php:79
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\T3editor\Registry
Definition: AddonRegistry.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50