ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
9use ILIAS\UI\Renderer as RendererInterface;
11
17{
21 public function render(Component\Component $component, RendererInterface $default_renderer)
22 {
26 $this->checkComponent($component);
27
28 $component = $this->registerSignals($component);
29 $this->bindJavaScript($component);
30 return $component->getContent();
31 }
32
36 protected function getComponentInterfaceName()
37 {
38 return [Component\Legacy\Legacy::class];
39 }
40
45 protected function registerSignals(Legacy $component)
46 {
47 $custom_signals = $component->getAllCustomSignals();
48
49 return $component->withAdditionalOnLoadCode(function ($id) use ($custom_signals) {
50 $code = "";
51 foreach ($custom_signals as $custom_signal) {
52 $signal_id = $custom_signal['signal'];
53 $signal_code = $custom_signal['js_code'];
54 $code .= "$(document).on('$signal_id', function(event, signalData) { $signal_code });";
55 }
56 return $code;
57 });
58 }
59}
An exception for terminatinating execution or to throw for unit testing.
getAllCustomSignals()
Get a list of all registered signals and their custom JavaScript code.
Definition: Legacy.php:95
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
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