ILIAS  release_7 Revision v7.30-3-g800a261c036
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;
12
18{
22 public function render(Component\Component $component, RendererInterface $default_renderer)
23 {
27 $this->checkComponent($component);
28
29 $component = $this->registerSignals($component);
30 $this->bindJavaScript($component);
31 return $component->getContent();
32 }
33
37 protected function getComponentInterfaceName()
38 {
39 return [Component\Legacy\Legacy::class];
40 }
41
46 protected function registerSignals(Legacy $component)
47 {
48 $custom_signals = $component->getAllCustomSignals();
49
50 return $component->withAdditionalOnLoadCode(function ($id) use ($custom_signals) {
51 $code = "";
52 foreach ($custom_signals as $custom_signal) {
53 $signal_id = $custom_signal['signal'];
54 $signal_code = $custom_signal['js_code'];
55 $code .= "$(document).on('$signal_id', function(event, signalData) { $signal_code });";
56 }
57 return $code;
58 });
59 }
60}
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