ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
DecoratedRenderer.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
25 
26 abstract class DecoratedRenderer implements Renderer
27 {
28  private $default;
29 
30  public function __construct(Renderer $default)
31  {
32  $this->default = $default;
33  }
34 
39  {
40  $clone = clone $this;
41  $clone->default = $clone->default->withAdditionalContext($context);
42  return $clone;
43  }
44 
52  abstract protected function manipulateRendering($component, Renderer $root): ?string;
53 
58  protected function manipulateAsyncRendering($component, Renderer $root): ?string
59  {
60  return null;
61  }
62 
67  final protected function renderDefault($component, ?Renderer $root = null): string
68  {
69  $root = $root ?? $this;
70  return $this->default->render($component, $root);
71  }
72 
76  final public function render($component, ?Renderer $root = null): string
77  {
78  $root = $root ?? $this;
79  return $this->manipulateRendering($component, $root) ?? $this->default->render($component, $root);
80  }
81 
85  final public function renderAsync($component, ?Renderer $root = null): string
86  {
87  $root = $root ?? $this;
88  return $this->manipulateAsyncRendering($component, $root) ?? $this->default->renderAsync($component, $root);
89  }
90 }
An entity that renders components to a string output.
Definition: Renderer.php:30
$context
Definition: webdav.php:29
render($component, ?Renderer $root=null)
Render given component.
renderAsync($component, ?Renderer $root=null)
Same as render, except that this version also returns any javascript code bound to the on load event...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderDefault($component, ?Renderer $root=null)
Renders the component by default.
manipulateAsyncRendering($component, Renderer $root)
Manipulates the async Rendering separately if needed.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withAdditionalContext(Component $context)
Get a new renderer with an additional context.A context makes it possible to use another renderer for...
render($component, ?Renderer $root=null)
Render given component.If an array of components is passed, this method returns a concatenated output...
manipulateRendering($component, Renderer $root)
Manipulates the rendering of one or multiple components by appending, prepending or exchanging their ...