ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
expandable2.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
4 class DataNode
5 {
6  public function __construct(string $label, array $children = [])
7  {
8  $this->label = $label;
9  $this->children = $children;
10  }
11  public function getLabel()
12  {
13  return $this->label;
14  }
15  public function getChildren()
16  {
17  return $this->children;
18  }
19 }
20 
21 function expandable2()
22 {
23  global $DIC;
24  $f = $DIC->ui()->factory();
25  $renderer = $DIC->ui()->renderer();
26 
27 
28  $n11 = new DataNode('1.1');
29  $n12 = new DataNode('1.2', array(new DataNode('1.2.1')));
30  $n1 = new DataNode('1', [$n11, $n12]);
31  $data = [$n1];
32 
33  $recursion = new class implements \ILIAS\UI\Component\Tree\TreeRecursion {
34  public function getChildren($record, $environment = null) : array
35  {
36  return $record->getChildren();
37  }
38 
39  public function build(
40  \ILIAS\UI\Component\Tree\Node\Factory $factory,
41  $record,
42  $environment = null
44  return $factory->simple($record->getLabel());
45  }
46  };
47 
48  $tree = $f->tree()->expandable("Label", $recursion)
49  ->withData($data);
50 
51  return $renderer->render($tree);
52 }
expandable2()
Definition: expandable2.php:21
$data
Definition: storeScorm.php:23
This describes a Tree Node.
Definition: Node.php:15
__construct(string $label, array $children=[])
Definition: expandable2.php:6
$DIC
Definition: xapitoken.php:46
$factory
Definition: metadata.php:58