ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
TestComponent.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
7use \ILIAS\UI\Implementation\Render\ResourceRegistry;
9use \ILIAS\UI\Renderer as DefaultRenderer;
10use \ILIAS\UI\Component\Component;
12
14{
16
17 public function __construct($text)
18 {
19 $this->text = $text;
20 }
21}
22
24{
27
28 public function __construct($text)
29 {
30 $this->text = $text;
31 }
32}
33
35{
36 final public function __construct($ui_factory, $tpl_factory, $lng, $js_binding)
37 {
38 $this->ui_factory = $ui_factory;
39 $this->tpl_factory = $tpl_factory;
40 $this->lng = $lng;
41 $this->js_binding = $js_binding;
42 }
43
44 public function render(Component $component, DefaultRenderer $default_renderer)
45 {
46 if ($component instanceof JSTestComponent) {
47 $text = $component->text;
48 $component = $component->withAdditionalOnLoadCode(function ($id) use ($text) {
49 return "id:$text.$id content:$text";
50 });
51 $this->bindOnloadCode($component);
52 }
53 return $component->text;
54 }
55
56 public function registerResources(ResourceRegistry $registry)
57 {
58 $registry->register("test.js");
59 }
60
61 private function bindOnloadCode(\ILIAS\UI\Component\JavaScriptBindable $component)
62 {
63 $binder = $component->getOnLoadCode();
64 $this->js_binding->addOnLoadCode($binder("id"));
65 }
66}
An exception for terminatinating execution or to throw for unit testing.
bindOnloadCode(\ILIAS\UI\Component\JavaScriptBindable $component)
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
render(Component $component, DefaultRenderer $default_renderer)
__construct($ui_factory, $tpl_factory, $lng, $js_binding)
A component is the most general form of an entity in the UI.
Definition: Component.php:14
Interface to be extended by components that have the possibility to bind to Javascript.
An entity that renders components to a string output.
Registry for resources required by rendered output like Javascript or CSS.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$lng