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
32{
36 public function render(Component\Component $component, RendererInterface $default_renderer): string
37 {
38 if (!$component instanceof Component\MessageBox\MessageBox) {
39 $this->cannotHandleComponent($component);
40 }
41
42 $ui_fac = $this->getUIFactory();
43 $tpl = $this->getTemplate("tpl.messagebox.html", true, true);
44
45 $buttons = $component->getButtons();
46 if (count($buttons) > 0) {
47 $tpl->setCurrentBlock("buttons");
48 $tpl->setVariable("BUTTONS", $default_renderer->render($buttons));
49 $tpl->parseCurrentBlock();
50 }
51
52 $tpl->setCurrentBlock("message_box");
53
54 $tpl->setVariable("MESSAGE_TEXT", $component->getMessageText());
55 $tpl->setVariable("ACC_TEXT", $this->txt($component->getType() . "_message"));
56 if ($component->getType() == Component\MessageBox\MessageBox::FAILURE) {
57 $tpl->setVariable("ROLE", "alert");
58 } else {
59 $tpl->setVariable("ROLE", "status");
60 }
61
62
63 $links = $component->getLinks();
64 if (count($links) > 0) {
65 $unordered = $ui_fac->listing()->unordered(
66 $links
67 );
68
69 $tpl->setVariable("LINK_LIST", $default_renderer->render($unordered));
70 }
71
72 $tpl->touchBlock($component->getType() . "_class");
73
74 $tpl->parseCurrentBlock();
75
76 return $tpl->get();
77 }
78}
render(Component\Component $component, RendererInterface $default_renderer)
@inheritdocs
Definition: Renderer.php:36
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
@ FAILURE
The progress of the process/task cannot be calculated (yet), but it has started processing.
Definition: Status.php:42