ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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  if ($component instanceof Component\Entity\Entity) {
38  return $this->renderEntity($component, $default_renderer);
39  }
40  $this->cannotHandleComponent($component);
41  }
42 
43  protected function renderEntity(Entity $component, RendererInterface $default_renderer): string
44  {
45  $tpl = $this->getTemplate('tpl.entity.html', true, true);
46  $secondary_identifier = $component->getSecondaryIdentifier();
47 
48  if (is_string($secondary_identifier)) {
49  $tpl->touchBlock('secondid_string');
50  } elseif ($secondary_identifier instanceof Component\Image\Image) {
51  $tpl->touchBlock('secondid_image');
52  } elseif ($secondary_identifier instanceof Component\Image\Symbol) {
53  $tpl->touchBlock('secondid_symbol');
54  } elseif ($secondary_identifier instanceof Component\Image\Link) {
55  $tpl->touchBlock('secondid_link');
56  } elseif ($secondary_identifier instanceof Component\Image\Shy) {
57  $tpl->touchBlock('secondid_shy');
58  }
59 
60  $tpl->setVariable('SECONDARY_IDENTIFIER', is_string($secondary_identifier) ? $secondary_identifier : $this->maybeRender($default_renderer, $secondary_identifier));
61 
62  $primary_identifier = $component->getPrimaryIdentifier();
63  $primary_identifier = is_string($primary_identifier) ? $primary_identifier : $this->maybeRender($default_renderer, $primary_identifier);
64  $tpl->setVariable('PRIMARY_IDENTIFIER', $primary_identifier);
65 
66  $tpl->setVariable('BLOCKING_CONDITIONS', $this->maybeRender($default_renderer, ...$component->getBlockingAvailabilityConditions()));
67  $tpl->setVariable('FEATURES', $this->maybeRender($default_renderer, ...$component->getFeaturedProperties()));
68  $tpl->setVariable('PERSONAL_STATUS', $this->maybeRender($default_renderer, ...$component->getPersonalStatus()));
69  $tpl->setVariable('MAIN_DETAILS', $this->maybeRender($default_renderer, ...$component->getMainDetails()));
70  $tpl->setVariable('AVAILABILITY', $this->maybeRender($default_renderer, ...$component->getAvailability()));
71  $tpl->setVariable('DETAILS', $this->maybeRender($default_renderer, ...$component->getDetails()));
72 
73  if ($actions = $component->getActions()) {
74  $actions_dropdown = $this->getUIFactory()->dropdown()->standard($actions);
75  $tpl->setVariable('ACTIONS', $default_renderer->render($actions_dropdown));
76  }
77  if ($reactions = $component->getReactions()) {
78  $tpl->setVariable('REACTIONS', $default_renderer->render($reactions));
79  }
80  if ($prio_reactions = $component->getPrioritizedReactions()) {
81  $tpl->setVariable('PRIO_REACTIONS', $default_renderer->render($prio_reactions));
82  }
83 
84  return $tpl->get();
85  }
86 
87  protected function maybeRender(RendererInterface $default_renderer, Component\Component | null ...$values): ?string
88  {
89  //$values = array_filter($values);
90  if ($values === []) {
91  return null;
92  }
93 
94  return $default_renderer->render($values);
95  }
96 }
This describes a symbol.
Definition: Symbol.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
renderEntity(Entity $component, RendererInterface $default_renderer)
Definition: Renderer.php:43
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:87
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:35
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.