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;
27
29{
33 public function render(Component\Component $component, RendererInterface $default_renderer): string
34 {
35 if (!$component instanceof Component\Deck\Deck) {
36 $this->cannotHandleComponent($component);
37 }
38
39 $tpl_card = $this->getTemplate("tpl.deck_card.html", true, true);
40 $tpl_row = $this->getTemplate("tpl.deck_row.html", true, true);
41
42 foreach ($component->getCards() as $card) {
43 $tpl_card->setCurrentBlock("card");
44 $tpl_card->setVariable("CARD", $default_renderer->render($card));
45 $tpl_card->setVariable("SIZE_MD", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_M));
46 $tpl_card->setVariable("SIZE_SM", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_S));
47 $tpl_card->setVariable("SIZE_XS", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_XS));
48 $tpl_card->setVariable("SIZE_LG", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_L));
49 $tpl_card->parseCurrentBlock();
50 }
51
52 $this->parseRow($tpl_row, $tpl_card->get());
53
54 return $tpl_row->get();
55 }
56
57 protected function parseRow(Template $tpl_row, string $content): void
58 {
59 $tpl_row->setCurrentBlock("row");
60 $tpl_row->setVariable("CARDS", $content);
61 $tpl_row->parseCurrentBlock();
62 }
63}
parseRow(Template $tpl_row, string $content)
Definition: Renderer.php:57
render(Component\Component $component, RendererInterface $default_renderer)
@inheritdocs
Definition: Renderer.php:33
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.
const SIZE_XS
Different sizes of the card.
Definition: Deck.php:42
Interface to templating as it is used in the UI framework.
Definition: Template.php:29
setVariable(string $name, $value)
Set a variable in the current block.
setCurrentBlock(string $name)
Set the block to work on.
parseCurrentBlock()
Parse the block that is currently worked on.
An entity that renders components to a string output.
Definition: Renderer.php:31