*/ private array $components = []; /** * @param array $sidebarComponents Pre-ordered components (injected by SidebarComponentsPass) */ public function __construct(array $sidebarComponents = []) { foreach ($sidebarComponents as $identifier => $component) { $this->components[$identifier] = $component; } } /** * Get all sidebar components. * * @return array */ public function getComponents(): array { return $this->components; } public function hasComponent(string $identifier): bool { return isset($this->components[$identifier]); } /** * @throws \InvalidArgumentException if component does not exist */ public function getComponent(string $identifier): SidebarComponentInterface { if (!$this->hasComponent($identifier)) { throw new \InvalidArgumentException( sprintf('Sidebar component with identifier "%s" is not registered', $identifier), 1765923035 ); } return $this->components[$identifier]; } }