ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
simpleWithLink.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
17 function simpleWithLink()
18 {
19  global $DIC;
20  $factory = $DIC->ui()->factory();
21  $renderer = $DIC->ui()->renderer();
22 
23  $icon = $factory->symbol()
24  ->icon()
25  ->standard("crs", 'Example');
26 
27  $node1 = $factory->tree()
28  ->node()
29  ->simple('label');
30 
31 
32  $uri = new \ILIAS\Data\URI('https://ilias.de');
33 
34  $node2 = $factory->tree()
35  ->node()
36  ->simple('label', $icon, $uri);
37 
38  $data = [['node' => $node1], ['node' => $node2]];
39 
40  $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
41  public function getChildren($record, $environment = null): array
42  {
43  return [];
44  }
45 
46  public function build(
47  \ILIAS\UI\Component\Tree\Node\Factory $factory,
48  $record,
49  $environment = null
50  ): \ILIAS\UI\Component\Tree\Node\Node {
51  return $record['node'];
52  }
53  };
54 
55  $tree = $factory->tree()->expandable('Label', $recursion)
56  ->withData($data);
57 
58  return $renderer->render([$tree]);
59 }
$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
simpleWithLink()
description: > Example for rendering a simple tree node with a link.