ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
expandable2.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
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
21function 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}
An exception for terminatinating execution or to throw for unit testing.
__construct(string $label, array $children=[])
Definition: expandable2.php:6
expandable2()
Definition: expandable2.php:21
This describes a Tree Node.
Definition: Node.php:16
$factory
Definition: metadata.php:58
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46