ILIAS  release_7 Revision v7.30-3-g800a261c036
expandable2.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
5{
9 protected $label = "";
10
14 protected $children = [];
15
16 public function __construct(string $label, array $children = [])
17 {
18 $this->label = $label;
19 $this->children = $children;
20 }
21 public function getLabel()
22 {
23 return $this->label;
24 }
25 public function getChildren()
26 {
27 return $this->children;
28 }
29}
30
31function expandable2()
32{
33 global $DIC;
34 $f = $DIC->ui()->factory();
35 $renderer = $DIC->ui()->renderer();
36
37
38 $n11 = new DataNode('1.1');
39 $n12 = new DataNode('1.2', array(new DataNode('1.2.1')));
40 $n1 = new DataNode('1', [$n11, $n12]);
41 $data = [$n1];
42
43 $recursion = new class implements \ILIAS\UI\Component\Tree\TreeRecursion {
44 public function getChildren($record, $environment = null) : array
45 {
46 return $record->getChildren();
47 }
48
49 public function build(
50 \ILIAS\UI\Component\Tree\Node\Factory $factory,
51 $record,
52 $environment = null
54 return $factory->simple($record->getLabel());
55 }
56 };
57
58 $tree = $f->tree()->expandable("Label", $recursion)
59 ->withData($data);
60
61 return $renderer->render($tree);
62}
An exception for terminatinating execution or to throw for unit testing.
__construct(string $label, array $children=[])
Definition: expandable2.php:16
expandable2()
Definition: expandable2.php:31
global $DIC
Definition: goto.php:24
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