ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
simple.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
17 function simple()
18 {
19  global $DIC;
20  $f = $DIC->ui()->factory();
21  $renderer = $DIC->ui()->renderer();
22 
23  $icon = $f->symbol()->icon()->standard("crs", 'Example');
24 
25  $node1 = $f->tree()->node()->simple('label');
26  $node2 = $f->tree()->node()->simple('label', $icon);
27 
28  $data = [['node' => $node1], ['node' => $node2]];
29 
30  $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
31  public function getChildren($record, $environment = null): array
32  {
33  return [];
34  }
35 
36  public function build(
37  \ILIAS\UI\Component\Tree\Node\Factory $factory,
38  $record,
39  $environment = null
40  ): \ILIAS\UI\Component\Tree\Node\Node {
41  return $record['node'];
42  }
43  };
44 
45  $tree = $f->tree()->expandable('Label', $recursion)
46  ->withData($data);
47 
48  return $renderer->render($tree);
49 }
$renderer
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is how the factory for UI elements looks.
Definition: Factory.php:37
global $DIC
Definition: shib_login.php:25
simple()
description: > Example for rendering a simple tree node.
Definition: simple.php:17