ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
Renderer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 //use ILIAS\UI\Component\JavaScriptBindable;
29 
31 {
35  public function render(Component\Component $component, RendererInterface $default_renderer): string
36  {
37  $this->checkComponent($component);
38  return $this->renderEntity($component, $default_renderer);
39  }
40 
41  protected function renderEntity(Entity $component, RendererInterface $default_renderer): string
42  {
43  $tpl = $this->getTemplate('tpl.entity.html', true, true);
44  $secondary_identifier = $component->getSecondaryIdentifier();
45 
46  if (is_string($secondary_identifier)) {
47  $tpl->touchBlock('secondid_string');
48  } elseif ($secondary_identifier instanceof Component\Image\Image) {
49  $tpl->touchBlock('secondid_image');
50  } elseif ($secondary_identifier instanceof Component\Image\Symbol) {
51  $tpl->touchBlock('secondid_symbol');
52  } elseif ($secondary_identifier instanceof Component\Image\Link) {
53  $tpl->touchBlock('secondid_link');
54  } elseif ($secondary_identifier instanceof Component\Image\Shy) {
55  $tpl->touchBlock('secondid_shy');
56  }
57 
58  $tpl->setVariable('SECONDARY_IDENTIFIER', is_string($secondary_identifier) ? $secondary_identifier : $this->maybeRender($default_renderer, $secondary_identifier));
59 
60  $primary_identifier = $component->getPrimaryIdentifier();
61  $primary_identifier = is_string($primary_identifier) ? $primary_identifier : $this->maybeRender($default_renderer, $primary_identifier);
62  $tpl->setVariable('PRIMARY_IDENTIFIER', $primary_identifier);
63 
64  $tpl->setVariable('BLOCKING_CONDITIONS', $this->maybeRender($default_renderer, ...$component->getBlockingAvailabilityConditions()));
65  $tpl->setVariable('FEATURES', $this->maybeRender($default_renderer, ...$component->getFeaturedProperties()));
66  $tpl->setVariable('PERSONAL_STATUS', $this->maybeRender($default_renderer, ...$component->getPersonalStatus()));
67  $tpl->setVariable('MAIN_DETAILS', $this->maybeRender($default_renderer, ...$component->getMainDetails()));
68  $tpl->setVariable('AVAILABILITY', $this->maybeRender($default_renderer, ...$component->getAvailability()));
69  $tpl->setVariable('DETAILS', $this->maybeRender($default_renderer, ...$component->getDetails()));
70 
71  if ($actions = $component->getActions()) {
72  $actions_dropdown = $this->getUIFactory()->dropdown()->standard($actions);
73  $tpl->setVariable('ACTIONS', $default_renderer->render($actions_dropdown));
74  }
75  if ($reactions = $component->getReactions()) {
76  $tpl->setVariable('REACTIONS', $default_renderer->render($reactions));
77  }
78  if ($prio_reactions = $component->getPrioritizedReactions()) {
79  $tpl->setVariable('PRIO_REACTIONS', $default_renderer->render($prio_reactions));
80  }
81 
82  return $tpl->get();
83  }
84 
85  protected function maybeRender(RendererInterface $default_renderer, Component\Component | null ...$values): ?string
86  {
87  //$values = array_filter($values);
88  if ($values === []) {
89  return null;
90  }
91 
92  return $default_renderer->render($values);
93  }
94 
98  protected function getComponentInterfaceName(): array
99  {
100  return [
101  Component\Entity\Standard::class
102  ];
103  }
104 }
This describes a symbol.
Definition: Symbol.php:29
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderEntity(Entity $component, RendererInterface $default_renderer)
Definition: Renderer.php:41
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
maybeRender(RendererInterface $default_renderer, Component\Component|null ... $values)
Definition: Renderer.php:85
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:35