ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Renderer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
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 }
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.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
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:57