ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Renderer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Renderer as RendererInterface;
26
28{
32 public function render(Component\Component $component, RendererInterface $default_renderer): string
33 {
34 if ($component instanceof Component\Divider\Horizontal) {
35 return $this->renderDividerHorizontal($component);
36 }
37 if ($component instanceof Component\Divider\Vertical) {
38 return $this->renderDividerVertical();
39 }
40 $this->cannotHandleComponent($component);
41 }
42
43 protected function renderDividerHorizontal(Component\Divider\Horizontal $component): string
44 {
45 $tpl = $this->getTemplate("tpl.horizontal.html", true, true);
46
47 $label = $component->getLabel();
48
49 if ($label !== null) {
50 $tpl->setCurrentBlock("label");
51 $tpl->setVariable("LABEL", $label);
52 $tpl->parseCurrentBlock();
53 $tpl->touchBlock("with_label");
54 } else {
55 $tpl->touchBlock("divider");
56 }
57
58 return $tpl->get();
59 }
60
61 protected function renderDividerVertical(): string
62 {
63 $tpl = $this->getTemplate("tpl.vertical.html", true, true);
64
65 $tpl->touchBlock("divider");
66
67 return $tpl->get();
68 }
69}
renderDividerHorizontal(Component\Divider\Horizontal $component)
Definition: Renderer.php:43
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:32
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
An entity that renders components to a string output.
Definition: Renderer.php:31