ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
StandardToastRendererFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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:
52  $renderer = new StandardToastRenderer($this->ui);
53  break;
54  case StandardToastItem::class:
55  $renderer = new StandardToastRenderer($this->ui);
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Provides fluid interface to RBAC services.
Definition: UIServices.php:24