diff --git a/components/ILIAS/UI/src/Implementation/DefaultRenderer.php b/components/ILIAS/UI/src/Implementation/DefaultRenderer.php index cd0133743a35..94cb33f77145 100755 --- a/components/ILIAS/UI/src/Implementation/DefaultRenderer.php +++ b/components/ILIAS/UI/src/Implementation/DefaultRenderer.php @@ -47,14 +47,15 @@ public function __construct( /** * @inheritdoc */ - public function render($component, ?Renderer $root = null) + public function render(Component|array $component, ?Renderer $root = null): string { $this->language->loadLanguageModule('ui'); - $root = $root ?? $this; + $root ??= $this; $out = ''; if (is_array($component)) { + /** @var Component $_component */ foreach ($component as $_component) { $out .= $root->render($_component); } @@ -75,12 +76,13 @@ public function render($component, ?Renderer $root = null) /** * @inheritdoc */ - public function renderAsync($component, ?Renderer $root = null) + public function renderAsync(Component|array $component, ?Renderer $root = null): string { - $root = $root ?? $this; + $root ??= $this; $out = ''; if (is_array($component)) { + /** @var Component $_component */ foreach ($component as $_component) { $out .= $root->renderAsync($_component); } diff --git a/components/ILIAS/UI/src/Implementation/Render/DecoratedRenderer.php b/components/ILIAS/UI/src/Implementation/Render/DecoratedRenderer.php index 3d9331a66261..225d5f6b3eef 100755 --- a/components/ILIAS/UI/src/Implementation/Render/DecoratedRenderer.php +++ b/components/ILIAS/UI/src/Implementation/Render/DecoratedRenderer.php @@ -63,7 +63,7 @@ final protected function renderDefault($component, ?Renderer $root = null): stri /** * @inheritdoc */ - final public function render($component, ?Renderer $root = null): string + final public function render(Component|array $component, ?Renderer $root = null): string { $root = $root ?? $this; return $this->manipulateRendering($component, $root) ?? $this->default->render($component, $root); @@ -72,7 +72,7 @@ final public function render($component, ?Renderer $root = null): string /** * @inheritdoc */ - final public function renderAsync($component, ?Renderer $root = null): string + final public function renderAsync(Component|array $component, ?Renderer $root = null): string { $root = $root ?? $this; return $this->manipulateAsyncRendering($component, $root) ?? $this->default->renderAsync($component, $root); diff --git a/components/ILIAS/UI/src/Renderer.php b/components/ILIAS/UI/src/Renderer.php index 7042700c9b51..809cd13963b9 100755 --- a/components/ILIAS/UI/src/Renderer.php +++ b/components/ILIAS/UI/src/Renderer.php @@ -35,10 +35,8 @@ interface Renderer * * @param Component|Component[] $component * @param ?Renderer $root of renderers in the chain to be used for rendering sub components. - * - * @return string */ - public function render($component, ?Renderer $root = null); + public function render(Component|array $component, ?Renderer $root = null): string; /** * Same as render, except that this version also returns any javascript code bound to the on load event, @@ -47,8 +45,6 @@ public function render($component, ?Renderer $root = null); * * @param Component|Component[] $component * @param ?Renderer $root of renderers in the chain to be used for rendering sub components. - * - * @return string */ - public function renderAsync($component, ?Renderer $root = null); + public function renderAsync(Component|array $component, ?Renderer $root = null): string; } diff --git a/components/ILIAS/UI/src/examples/Table/Ordering/large.php b/components/ILIAS/UI/src/examples/Table/Ordering/large.php index 7e455a22d4cc..44764383f4eb 100644 --- a/components/ILIAS/UI/src/examples/Table/Ordering/large.php +++ b/components/ILIAS/UI/src/examples/Table/Ordering/large.php @@ -1,13 +1,27 @@ retrieve('ordering_example', $refinery->kindlyTo()->int()) === 4 ) { if ($data = $table->getData()) { - $out[] = $f->legacy('
' . print_r($data, true) . ''); + $out[] = $f->legacy()->content('
' . print_r($data, true) . ''); } $data_retrieval->setOrder($data); } diff --git a/components/ILIAS/UI/tests/Renderer/AbstractRendererTest.php b/components/ILIAS/UI/tests/Renderer/AbstractRendererTest.php index 17eea8a56a36..ce840cc8e9b9 100755 --- a/components/ILIAS/UI/tests/Renderer/AbstractRendererTest.php +++ b/components/ILIAS/UI/tests/Renderer/AbstractRendererTest.php @@ -73,6 +73,7 @@ public function _getTemplate(string $a, bool $b, bool $c): Template require_once(__DIR__ . "/../Base.php"); use ILIAS\UI\Component as C; + use ILIAS\UI\Component\Component; use ILIAS\UI\Implementation\Render\Template; use ILIAS\UI\Implementation\Render\TemplateFactory; use ILIAS\UI\Renderer; @@ -134,11 +135,12 @@ public function getTemplate(string $path, bool $purge_unfilled_vars, bool $purge class NullDefaultRenderer implements Renderer { - public function render($component, ?Renderer $root = null) + public function render(Component|array $component, ?Renderer $root = null): string { - return ""; + return ''; } - public function renderAsync($component, ?Renderer $root = null) + + public function renderAsync(Component|array $component, ?Renderer $root = null): string { return ''; }