widgets); } public function registerWidget(WidgetInterface $widget): void { $id = trim($widget->getId()); if ($id === '') { throw new \InvalidArgumentException('Widget needs a non-empty ID'); } $this->widgets[$id] = $widget; } /** * @return array */ public function getAllWidgets(): array { return $this->widgets; } public function getWidget(string $id): WidgetInterface { if (!$this->hasWidget($id)) { throw new \InvalidArgumentException(\sprintf('Cannot find widget: %s', $id)); } return $this->widgets[$id]; } }