2 declare(strict_types
= 1);
4 namespace TYPO3\CMS\Core\MetaTag
;
7 * This file is part of the TYPO3 CMS project.
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.
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
16 * The TYPO3 project - inspiring people to share!
19 use TYPO3\CMS\Core\Service\DependencyOrderingService
;
20 use TYPO3\CMS\Core\SingletonInterface
;
21 use TYPO3\CMS\Core\Utility\GeneralUtility
;
24 * Holds all available meta tag managers
26 class MetaTagManagerRegistry
implements SingletonInterface
28 protected $registry = [];
30 public function __construct()
32 $this->registry
['generic'] = [
33 'module' => GenericMetaTagManager
::class
38 * Add a MetaTagManager to the registry
41 * @param string $className
42 * @param array $before
45 public function registerManager(string $name, string $className, array $before = ['generic'], array $after = [])
47 if (!count($before)) {
48 $before[] = 'generic';
51 $this->registry
[$name] = [
52 'module' => $className,
59 * Get the MetaTagManager for a specific property
61 * @param string $property
62 * @return MetaTagManagerInterface
64 public function getManagerForProperty(string $property): MetaTagManagerInterface
66 $property = strtolower($property);
67 foreach ($this->getAllManagers() as $manager) {
68 if ($manager->canHandleProperty($property)) {
73 // Just a fallback because the GenericMetaTagManager is also registered in the list of MetaTagManagers
74 return GeneralUtility
::makeInstance(GenericMetaTagManager
::class);
78 * Get an array of all registered MetaTagManagers
80 * @return MetaTagManagerInterface[]
82 public function getAllManagers(): array
84 $orderedManagers = GeneralUtility
::makeInstance(DependencyOrderingService
::class)->orderByDependencies(
89 foreach ($orderedManagers as $manager => $managerConfiguration) {
90 if (class_exists($managerConfiguration['module'])) {
91 $managers[$manager] = GeneralUtility
::makeInstance($managerConfiguration['module']);
99 * Remove all registered MetaTagManagers
101 public function removeAllManagers()
103 unset($this->registry
);