‪TYPO3CMS  10.4
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 
39  public static function ‪getInstance(): ‪AddonRegistry
40  {
41  return GeneralUtility::makeInstance(static::class);
42  }
43 
50  public function register(‪Addon $addon): ‪AddonRegistry
51  {
52  $this->registeredAddons[$addon->getIdentifier()] = $addon;
53 
54  return $this;
55  }
56 
61  public function ‪getForMode(string $mode = ''): array
62  {
63  $addons = [];
64 
65  foreach ($this->registeredAddons as $addon) {
66  if (empty($addon->getModes()) || in_array($mode, $addon->getModes(), true)) {
67  $addons[] = $addon;
68  }
69  }
70 
71  return $addons;
72  }
73 
78  public function ‪compileSettings(array $addons): array
79  {
80  $settings = [];
81  foreach ($addons as $addon) {
82  $settings = array_merge($settings, $addon->getOptions());
83  }
84 
85  return $settings;
86  }
87 }
‪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:38
‪TYPO3\CMS\T3editor\Addon
Definition: Addon.php:25
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\getForMode
‪Addon[] getForMode(string $mode='')
Definition: AddonRegistry.php:60
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\compileSettings
‪array compileSettings(array $addons)
Definition: AddonRegistry.php:77
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪TYPO3\CMS\T3editor\Registry
Definition: AddonRegistry.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46