Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions components/ILIAS/UI/src/Implementation/DefaultRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 2 additions & 6 deletions components/ILIAS/UI/src/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
20 changes: 17 additions & 3 deletions components/ILIAS/UI/src/examples/Table/Ordering/large.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<?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);

namespace ILIAS\UI\examples\Table\Ordering;

use ILIAS\UI\Implementation\Component\Table as T;
use ILIAS\UI\Component\Table as I;
use ILIAS\UI\URLBuilder;
use Psr\Http\Message\ServerRequestInterface;
use ILIAS\Data\URI;

/**
Expand Down Expand Up @@ -135,7 +149,7 @@ public function setOrder(array $ordered): void
&& $request_wrapper->retrieve('ordering_example', $refinery->kindlyTo()->int()) === 4
) {
if ($data = $table->getData()) {
$out[] = $f->legacy('<pre>' . print_r($data, true) . '</pre>');
$out[] = $f->legacy()->content('<pre>' . print_r($data, true) . '</pre>');
}
$data_retrieval->setOrder($data);
}
Expand Down
8 changes: 5 additions & 3 deletions components/ILIAS/UI/tests/Renderer/AbstractRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 '';
}
Expand Down