ILIAS  release_8 Revision v8.24
StandardToastRendererFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
31{
32 protected array $renderers = [];
33 protected UIServices $ui;
34
35 public function __construct(UIServices $ui)
36 {
37 $this->ui = $ui;
38 }
39
40 public function getRenderer(string $fully_qualified): ToastRenderer
41 {
42 $renderer = $this->ensureRenderer($fully_qualified);
43 if (!$renderer instanceof \ILIAS\GlobalScreen\Scope\Toast\Collector\Renderer\ToastRenderer) {
44 throw new \InvalidArgumentException("Cannot render item of type " . $fully_qualified);
45 }
46 return $renderer;
47 }
48
49 public function buildRenderer(string $fully_qualified): ?ToastRenderer
50 {
51 $renderer = null;
52 switch ($fully_qualified) {
53 case isStandardItem::class:
54 $renderer = new StandardToastRenderer($this->ui);
55 break;
56 case StandardToastItem::class:
57 $renderer = new StandardToastRenderer($this->ui);
58 break;
59 default:
60 $renderer = null;
61 break;
62 }
63 return $renderer;
64 }
65
66 private function ensureRenderer(string $fully_qualified): ?ToastRenderer
67 {
68 if (!isset($this->renderers[$fully_qualified])) {
69 $this->renderers[$fully_qualified] = $this->buildRenderer($fully_qualified);
70 }
71 return $this->renderers[$fully_qualified];
72 }
73}
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
Class ChatMainBarProvider \MainMenu\Provider.