ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
simpleWithLink.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
33 function simpleWithLink()
34 {
35  global $DIC;
36  $factory = $DIC->ui()->factory();
37  $renderer = $DIC->ui()->renderer();
38 
39  $icon = $factory->symbol()
40  ->icon()
41  ->standard("crs", 'Example');
42 
43  $node1 = $factory->tree()
44  ->node()
45  ->simple('label');
46 
47 
48  $uri = new \ILIAS\Data\URI('https://ilias.de');
49 
50  $node2 = $factory->tree()
51  ->node()
52  ->simple('label', $icon, $uri);
53 
54  $data = [['node' => $node1], ['node' => $node2]];
55 
56  $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
57  public function getChildren($record, $environment = null): array
58  {
59  return [];
60  }
61 
62  public function build(
63  \ILIAS\UI\Component\Tree\Node\Factory $factory,
64  $record,
65  $environment = null
66  ): \ILIAS\UI\Component\Tree\Node\Node {
67  return $record['node'];
68  }
69  };
70 
71  $tree = $factory->tree()->expandable('Label', $recursion)
72  ->withData($data);
73 
74  return $renderer->render([$tree]);
75 }
$renderer
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
simpleWithLink()
description: > Example for rendering a simple tree node with a link.