ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
FooterRendererFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
31 
36 {
38  private readonly LinkItemRenderer $link_renderer;
40  private readonly NullItemRenderer $null_renderer;
41 
42  public function __construct(private readonly UIServices $ui)
43  {
44  $this->group_renderer = new GroupItemRenderer($this->ui, $this);
45  $this->link_renderer = new LinkItemRenderer($this->ui);
46  $this->modal_renderer = new ModalItemRenderer($this->ui);
47  $this->null_renderer = new NullItemRenderer($this->ui);
48  }
49 
50  public function getRendererFor(isItem $item): FooterItemRenderer
51  {
52  return match (true) {
53  $item instanceof Group => $this->group_renderer,
54  $item instanceof Link => $this->link_renderer,
55  $item instanceof Modal => $this->modal_renderer,
56  default => $this->null_renderer,
57  };
58  }
59 
60  public function addToFooter(isItem $item, Footer $footer): Footer
61  {
62  $renderer = $this->getRendererFor($item);
63  $component = $renderer->getComponentForItem($item);
64 
65  return match (true) {
66  $item instanceof Group => $footer->withAdditionalLinkGroup($item->getTitle(), $component),
67  $item instanceof Link => $item->hasParent() ? $footer : $footer->withAdditionalLink($component),
68  $item instanceof Modal => $footer->withAdditionalModal($item->getModal()),
69  $item instanceof Permanent => $footer->withPermanentURL($item->getURI()),
70  $item instanceof Text => $footer->withAdditionalText($item->getText()),
71  default => $footer,
72  };
73  }
74 
75 }
withAdditionalModal(Modal\RoundTrip $modal)
$renderer
withAdditionalLink(Link|Shy ... $actions)
Get a Footer like this but add an additional link or shy-button to the links section.
withAdditionalText(string ... $texts)
Get a Footer like this but add additional text information to the meta section.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
withAdditionalLinkGroup(string $title, array $actions)
Get a Footer like this but add an additional, named group of links or shy-buttons to the link-group s...
withPermanentURL(URI $url)
Get a Footer like this but with a permanent URL to the current page, which can be copied by the users...