forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorldRenderer.php
54 lines (47 loc) · 1.74 KB
/
HelloWorldRenderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*/
declare(strict_types=1);
use ILIAS\UI\Implementation\Component\Button\Bulky;
use ILIAS\UI\Implementation\Render\DecoratedRenderer;
use ILIAS\UI\Renderer;
use ILIAS\UI\Implementation\Render\JavaScriptBinding;
use ILIAS\UI\Implementation\Render\ResourceRegistry;
/**
* Extend the DecoratedRenderer to align your renderer with other potential renderers in ILIAS,
* and allow manipulations from different sources to be chained to one another.
*/
class HelloWorldRenderer extends DecoratedRenderer
{
public function __construct(ResourceRegistry $resource_registry, Renderer $default)
{
$this->registerResources($resource_registry);
parent::__construct($default);
}
protected function manipulateRendering($component, Renderer $root): ?string
{
// if the component is an instance of our custom implementation, we can
// render it according to our business logic and pass it to the chain.
if ($component instanceof HelloWorld) {
return "<p>{$component->getGreeting()}</p>";
}
// return null to indicate you are not interested in the given component.
return null;
}
protected function registerResources(ResourceRegistry $resource_registry): void
{
$resource_registry->register('some/asset/path');
}
}