‪TYPO3CMS  ‪main
ToolbarItemsRegistry.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 
25 {
26  protected array ‪$toolbarItems = [];
27 
28  public function ‪__construct(iterable ‪$toolbarItems)
29  {
30  foreach (‪$toolbarItems as $toolbarItem) {
31  if ($toolbarItem instanceof ‪ToolbarItemInterface) {
32  $index = (int)$toolbarItem->getIndex();
33  if ($index < 0 || $index > 100) {
34  throw new \RuntimeException(
35  'getIndex() must return an integer between 0 and 100',
36  1415968498
37  );
38  }
39  // Find next free position in array
40  while (isset($this->toolbarItems[$index])) {
41  $index++;
42  }
43  $this->toolbarItems[$index] = $toolbarItem;
44  }
45  }
46  ksort($this->toolbarItems);
47  }
48 
54  public function ‪getToolbarItems(): array
55  {
57  }
58 }
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface
Definition: ToolbarItemInterface.php:22
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemsRegistry
Definition: ToolbarItemsRegistry.php:25
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemsRegistry\$toolbarItems
‪array $toolbarItems
Definition: ToolbarItemsRegistry.php:26
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemsRegistry\getToolbarItems
‪ToolbarItemInterface[] getToolbarItems()
Definition: ToolbarItemsRegistry.php:54
‪TYPO3\CMS\Backend\Toolbar
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemsRegistry\__construct
‪__construct(iterable $toolbarItems)
Definition: ToolbarItemsRegistry.php:28