‪TYPO3CMS  9.5
AddonRegistry.php
Go to the documentation of this file.
1 <?php
2 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 
21 
27 {
31  protected ‪$registeredAddons = [];
32 
37  public static function ‪getInstance(): ‪AddonRegistry
38  {
39  return GeneralUtility::makeInstance(static::class);
40  }
41 
48  public function register(‪Addon $addon): ‪AddonRegistry
49  {
50  $this->registeredAddons[$addon->getIdentifier()] = $addon;
51 
52  return $this;
53  }
54 
59  public function ‪getForMode(string $mode = ''): array
60  {
61  $addons = [];
62 
63  foreach ($this->registeredAddons as $addon) {
64  if (empty($addon->getModes()) || in_array($mode, $addon->getModes(), true)) {
65  $addons[] = $addon;
66  }
67  }
68 
69  return $addons;
70  }
71 
76  public function ‪compileSettings(array $addons): array
77  {
78  $settings = [];
79  foreach ($addons as $addon) {
80  $settings = array_merge($settings, $addon->getOptions());
81  }
82 
83  return $settings;
84  }
85 }
‪TYPO3\CMS\T3editor\Registry\AddonRegistry
Definition: AddonRegistry.php:27
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\$registeredAddons
‪Addon[] $registeredAddons
Definition: AddonRegistry.php:30
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\getInstance
‪static self getInstance()
Definition: AddonRegistry.php:36
‪TYPO3\CMS\T3editor\Addon
Definition: Addon.php:23
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\getForMode
‪Addon[] getForMode(string $mode='')
Definition: AddonRegistry.php:58
‪TYPO3\CMS\T3editor\Registry\AddonRegistry\compileSettings
‪array compileSettings(array $addons)
Definition: AddonRegistry.php:75
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\T3editor\Registry
Definition: AddonRegistry.php:3
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45