ILIAS  release_7 Revision v7.30-3-g800a261c036
Tree.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4/* Copyright (c) 2019 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
5
7
10
14abstract class Tree implements ITree\Tree
15{
17
21 protected $environment;
22
26 protected $data;
27
31 protected $label;
32
36 protected $recursion;
37
41 protected $highlight_nodes_on_click = false;
42
46 protected $is_sub = false;
47
48
49 public function __construct(string $label, ITree\TreeRecursion $recursion)
50 {
51 $this->label = $label;
52 $this->recursion = $recursion;
53 }
54
58 public function getLabel() : string
59 {
60 return $this->label;
61 }
62
66 public function withEnvironment($environment) : ITree\Tree
67 {
68 $clone = clone $this;
69 $clone->environment = $environment;
70 return $clone;
71 }
72
76 public function withData($data) : ITree\Tree
77 {
78 $clone = clone $this;
79 $clone->data = $data;
80 return $clone;
81 }
82
86 public function getEnvironment()
87 {
88 return $this->environment;
89 }
90
94 public function getData()
95 {
96 return $this->data;
97 }
98
102 public function getRecursion() : ITree\TreeRecursion
103 {
104 return $this->recursion;
105 }
106
107
111 public function withHighlightOnNodeClick(bool $highlight_nodes_on_click) : ITree\Tree
112 {
113 $clone = clone $this;
114 $clone->highlight_nodes_on_click = $highlight_nodes_on_click;
115 return $clone;
116 }
117
121 public function getHighlightOnNodeClick() : bool
122 {
123 return $this->highlight_nodes_on_click;
124 }
125
129 public function isSubTree() : bool
130 {
131 return $this->is_sub;
132 }
133
137 public function withIsSubTree(bool $is_sub) : ITree\Tree
138 {
139 $clone = clone $this;
140 $clone->is_sub = $is_sub;
141 return $clone;
142 }
143}
An exception for terminatinating execution or to throw for unit testing.
getEnvironment()
Get the environment.
Definition: Tree.php:86
withIsSubTree(bool $is_sub)
Set this tree to be a part of a tree.Needed if parts are loaded async.
Definition: Tree.php:137
withHighlightOnNodeClick(bool $highlight_nodes_on_click)
Should a clicked node be highlighted?
Definition: Tree.php:111
withEnvironment($environment)
Configure the Tree with additional information that will be relayed to TreeRecursion.
Definition: Tree.php:66
__construct(string $label, ITree\TreeRecursion $recursion)
Definition: Tree.php:49
getHighlightOnNodeClick()
Is the tree configured to highlight a clicked node?
Definition: Tree.php:121
isSubTree()
Is this only a part of a tree? Needed if parts are loaded async.
Definition: Tree.php:129
withData($data)
Apply data to the Tree.
Definition: Tree.php:76
getRecursion()
Get the mapping-class.
Definition: Tree.php:102
Interface for mapping data-structures to the Tree.
This describes a Tree Control.
Definition: Tree.php:14
trait ComponentHelper
Provides common functionality for component implementations.
$data
Definition: storeScorm.php:23