ILIAS  release_7 Revision v7.30-3-g800a261c036
ExampleRenderer.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
23
29{
30 protected function manipulateRendering($component, Renderer $root) : ?string
31 {
32 // choose the component you want to manipulate by checking the instance
33 // as closely as possible. please note there may be custom components in
34 // the current chain, which may extend an interface or implementation,
35 // and also run into your manipulation.
36 if ($component instanceof Bulky) {
37 // render the component by passing it to the rendering chain of
38 // renderers that come before this renderer.
39 $html = $this->renderDefault($component);
40 // manipulate the html to your desire and/or replace it entirely.
41 $html .= 'my custom additions';
42 // finally pass the manipulated HTML to the cain, so other renderers
43 // that come after this may manipulate it too.
44 return $html;
45 }
46
47 // return null to indicate you are not interested in the given component.
48 return null;
49 }
50}
An exception for terminatinating execution or to throw for unit testing.
Extend the DecoratedRenderer to align your renderer with other potential renderers in ILIAS,...
manipulateRendering($component, Renderer $root)
Manipulates the rendering of one or multiple components by appending, prepending or exchanging their ...
renderDefault($component, ?Renderer $root=null)
Renders the component by default.
An entity that renders components to a string output.
Definition: Renderer.php:15