ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
DecoratedRenderer.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
3 /******************************************************************************
4  *
5  * This file is part of ILIAS, a powerful learning management system
6  * published by ILIAS open source e-Learning e.V.
7  *
8  * ILIAS is licensed with the GPL-3.0,
9  * see https://www.gnu.org/licenses/gpl-3.0.en.html
10  * You should have received a copy of said license along with the
11  * source code, too.
12  *
13  * If this is not the case or you just want to try ILIAS, you'll find
14  * us at:
15  * https://www.ilias.de
16  * https://github.com/ILIAS-eLearning
17  *
18  *****************************************************************************/
19 
21 
24 
25 abstract class DecoratedRenderer implements Renderer
26 {
27  private $default;
28 
29  public function __construct(Renderer $default)
30  {
31  $this->default = $default;
32  }
33 
38  {
39  $clone = clone $this;
40  $clone->default = $clone->default->withAdditionalContext($context);
41  return $clone;
42  }
43 
51  abstract protected function manipulateRendering($component, Renderer $root) : ?string;
52 
57  protected function manipulateAsyncRendering($component, Renderer $root) : ?string
58  {
59  return null;
60  }
61 
66  final protected function renderDefault($component, ?Renderer $root = null) : string
67  {
68  $root = $root ?? $this;
69  return $this->default->render($component, $root);
70  }
71 
75  final public function render($component, ?Renderer $root = null) : string
76  {
77  $root = $root ?? $this;
78  return $this->manipulateRendering($component, $root) ?? $this->default->render($component, $root);
79  }
80 
84  final public function renderAsync($component, ?Renderer $root = null) : string
85  {
86  $root = $root ?? $this;
87  return $this->manipulateAsyncRendering($component, $root) ?? $this->default->renderAsync($component, $root);
88  }
89 }
An entity that renders components to a string output.
Definition: Renderer.php:14
$context
Definition: webdav.php:26
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...
renderDefault($component, ?Renderer $root=null)
Renders the component by default.
manipulateAsyncRendering($component, Renderer $root)
Manipulates the async Rendering separately if needed.
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 ...