ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
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 }
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
getAllCustomSignals()
Get a list of all registered signals and their custom JavaScript code.
Definition: Legacy.php:95
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.