ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
Renderer.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
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 }
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
setCurrentBlock(string $name)
Set the block to work on.
setVariable(string $name, $value)
Set a variable in the current block.
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:33
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
parseCurrentBlock()
Parse the block that is currently worked on.
const SIZE_XS
Different sizes of the card.
Definition: Deck.php:42
parseRow(Template $tpl_row, string $content)
Definition: Renderer.php:53