ILIAS  release_8 Revision v8.24
Renderer.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
24use ILIAS\UI\Renderer as RendererInterface;
27
29{
33 public function render(Component\Component $component, RendererInterface $default_renderer): string
34 {
35 $tpl_card = $this->getTemplate("tpl.deck_card.html", true, true);
36 $tpl_row = $this->getTemplate("tpl.deck_row.html", true, true);
37
38 foreach ($component->getCards() as $card) {
39 $tpl_card->setCurrentBlock("card");
40 $tpl_card->setVariable("CARD", $default_renderer->render($card));
41 $tpl_card->setVariable("SIZE_MD", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_M));
42 $tpl_card->setVariable("SIZE_SM", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_S));
43 $tpl_card->setVariable("SIZE_XS", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_XS));
44 $tpl_card->setVariable("SIZE_LG", $component->getCardsSizeForDisplaySize(Component\Deck\Deck::SIZE_L));
45 $tpl_card->parseCurrentBlock();
46 }
47
48 $this->parseRow($tpl_row, $tpl_card->get());
49
50 return $tpl_row->get();
51 }
52
53 protected function parseRow(Template $tpl_row, string $content): void
54 {
55 $tpl_row->setCurrentBlock("row");
56 $tpl_row->setVariable("CARDS", $content);
57 $tpl_row->parseCurrentBlock();
58 }
59
63 protected function getComponentInterfaceName(): array
64 {
65 return array(Component\Deck\Deck::class);
66 }
67}
parseRow(Template $tpl_row, string $content)
Definition: Renderer.php:53
render(Component\Component $component, RendererInterface $default_renderer)
@inheritdocs
Definition: Renderer.php:33
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Deck.php:21