ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
Renderer.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
26 
32 {
36  public function render(Component\Component $component, RendererInterface $default_renderer): string
37  {
41  $this->checkComponent($component);
42 
43  $component = $this->registerSignals($component);
44  $this->bindJavaScript($component);
45  return $component->getContent();
46  }
47 
51  protected function getComponentInterfaceName(): array
52  {
53  return [Component\Legacy\Legacy::class];
54  }
55 
56  protected function registerSignals(Legacy $component): Component\JavaScriptBindable
57  {
58  $custom_signals = $component->getAllCustomSignals();
59 
60  return $component->withAdditionalOnLoadCode(function ($id) use ($custom_signals): string {
61  $code = "";
62  foreach ($custom_signals as $custom_signal) {
63  $signal_id = $custom_signal['signal'];
64  $signal_code = $custom_signal['js_code'];
65  $code .= "$(document).on('$signal_id', function(event, signalData) { $signal_code });";
66  }
67  return $code;
68  });
69  }
70 }
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAllCustomSignals()
Get a list of all registered signals and their custom JavaScript code.
Definition: Legacy.php:94
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.