ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Renderer.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4
6
8use ILIAS\UI\Renderer as RendererInterface;
10
16{
20 public function render(Component\Component $component, RendererInterface $default_renderer)
21 {
25 $this->checkComponent($component);
26 $tpl = $this->getTemplate("tpl.image.html", true, true);
27
28 if ($component->getAction()) {
29 $tpl->setCurrentBlock("action_begin");
30 $tpl->setVariable("HREF", $component->getAction());
31 $tpl->parseCurrentBlock();
32 }
33
34 $tpl->setCurrentBlock($component->getType());
35 $tpl->setVariable("SOURCE", $component->getSource());
36 $tpl->setVariable("ALT", htmlspecialchars($component->getAlt()));
37 $tpl->parseCurrentBlock();
38
39 if ($component->getAction()) {
40 $tpl->touchBlock("action_end");
41 }
42
43 return $tpl->get();
44 }
45
49 protected function getComponentInterfaceName()
50 {
51 return [Component\Image\Image::class];
52 }
53}
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
checkComponent(Component $component)
Check if a given component fits this renderer and throw \LogicError if that is not the case.
A component is the most general form of an entity in the UI.
Definition: Component.php:14
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
An entity that renders components to a string output.
Definition: Renderer.php:15