ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
34 public function __construct(protected UIServices $ui)
35 {
36 }
37
38 public function getRenderer(string $fully_qualified): ToastRenderer
39 {
40 $renderer = $this->ensureRenderer($fully_qualified);
41 if (!$renderer instanceof ToastRenderer) {
42 throw new \InvalidArgumentException("Cannot render item of type " . $fully_qualified);
43 }
44 return $renderer;
45 }
46
47 public function buildRenderer(string $fully_qualified): ?ToastRenderer
48 {
49 $renderer = null;
50 switch ($fully_qualified) {
51 case isStandardItem::class:
53 break;
54 case StandardToastItem::class:
56 break;
57 default:
58 $renderer = null;
59 break;
60 }
61 return $renderer;
62 }
63
64 private function ensureRenderer(string $fully_qualified): ?ToastRenderer
65 {
66 if (!isset($this->renderers[$fully_qualified])) {
67 $this->renderers[$fully_qualified] = $this->buildRenderer($fully_qualified);
68 }
69 return $this->renderers[$fully_qualified];
70 }
71}
$renderer
Provides fluid interface to RBAC services.
Definition: UIServices.php:25