ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
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 
29 
31 {
35  public function render(Component\Component $component, RendererInterface $default_renderer): string
36  {
37  switch(true) {
38  case ($component instanceof Component\Layout\Alignment\Vertical):
39  return $this->renderAlignment($component, $default_renderer);
40 
41  default:
42  $this->cannotHandleComponent($component);
43  }
44  }
45 
46  protected function renderAlignment(
47  I\Vertical $component,
48  RendererInterface $default_renderer
49  ): string {
50  $tpl = $this->getTemplate('tpl.alignment.html', true, true);
51  foreach ($component->getBlocks() as $idx => $block) {
52  $tpl->setCurrentBlock('block');
53  $tpl->setVariable('CONTENT', $default_renderer->render($block));
54  $tpl->parseCurrentBlock();
55  }
56  $tpl->touchBlock('alignment_vertical');
57  return $tpl->get();
58  }
59 }
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:35
renderAlignment(I\Vertical $component, RendererInterface $default_renderer)
Definition: Renderer.php:46
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.