‪TYPO3CMS  ‪main
ElementBrowserRegistry.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 
27 {
31  private array ‪$elementBrowsers = [];
32 
33  public function ‪__construct(iterable ‪$elementBrowsers)
34  {
35  foreach (‪$elementBrowsers as $elementBrowser) {
36  if (!($elementBrowser instanceof ‪ElementBrowserInterface)) {
37  continue;
38  }
39 
40  ‪$identifier = $elementBrowser->getIdentifier();
41  if (‪$identifier === '') {
42  throw new \InvalidArgumentException('Identifier for element browser ' . get_class($elementBrowser) . ' is empty.', 1647241084);
43  }
44  if (isset($this->elementBrowsers[‪$identifier])) {
45  throw new \InvalidArgumentException('Element browser with identifier ' . ‪$identifier . ' is already registered.', 1647241085);
46  }
47  $this->elementBrowsers[‪$identifier] = $elementBrowser;
48  }
49  }
50 
54  public function ‪hasElementBrowser(string ‪$identifier): bool
55  {
56  return isset($this->elementBrowsers[‪$identifier]);
57  }
58 
63  {
64  if (!$this->‪hasElementBrowser($identifier)) {
65  throw new \UnexpectedValueException('Element browser with identifier ' . ‪$identifier . ' is not registered.', 1647241086);
66  }
67 
68  return $this->elementBrowsers[‪$identifier];
69  }
70 
76  public function ‪getElementBrowsers(): array
77  {
79  }
80 }
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserInterface
Definition: ElementBrowserInterface.php:28
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserRegistry\hasElementBrowser
‪hasElementBrowser(string $identifier)
Definition: ElementBrowserRegistry.php:54
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserRegistry\getElementBrowsers
‪ElementBrowserInterface[] getElementBrowsers()
Definition: ElementBrowserRegistry.php:76
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserRegistry\__construct
‪__construct(iterable $elementBrowsers)
Definition: ElementBrowserRegistry.php:33
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserRegistry\getElementBrowser
‪getElementBrowser(string $identifier)
Definition: ElementBrowserRegistry.php:62
‪TYPO3\CMS\Backend\ElementBrowser
Definition: AbstractElementBrowser.php:18
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserRegistry
Definition: ElementBrowserRegistry.php:27
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserRegistry\$elementBrowsers
‪array $elementBrowsers
Definition: ElementBrowserRegistry.php:31
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37