ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractBaseItem.php
Go to the documentation of this file.
2 
6 
12 abstract class AbstractBaseItem implements isItem
13 {
14 
18  protected $position = 0;
26  protected $available_callable = true;
30  protected $active_callable;
42  protected $is_always_available = false;
46  protected $type_information;
47 
48 
55  {
56  $this->provider_identification = $provider_identification;
57  }
58 
59 
64  {
66  }
67 
68 
72  public function withVisibilityCallable(callable $is_visible) : isItem
73  {
74  $clone = clone($this);
75  $clone->visiblility_callable = $is_visible;
76 
77  return $clone;
78  }
79 
80 
84  public function isVisible() : bool
85  {
86  if (!$this->isAvailable()) {
87  return false;
88  }
89  if (is_callable($this->visiblility_callable)) {
90  $callable = $this->visiblility_callable;
91 
92  $value = $callable();
93 
94  return $value;
95  }
96 
97  return true;
98  }
99 
100 
104  public function withActiveCallable(callable $is_active) : isItem
105  {
106  $clone = clone($this);
107  $clone->active_callable = $is_active;
108 
109  return $clone;
110  }
111 
112 
116  public function isActive() : bool
117  {
118  if (is_callable($this->active_callable)) {
119  $callable = $this->active_callable;
120 
121  $value = $callable();
122 
123  return $value;
124  }
125 
126  return true;
127  }
128 
129 
133  public function withAvailableCallable(callable $is_available) : isItem
134  {
135  $clone = clone($this);
136  $clone->available_callable = $is_available;
137 
138  return $clone;
139  }
140 
141 
145  public function isAvailable() : bool
146  {
147  if ($this->isAlwaysAvailable() === true) {
148  return true;
149  }
150  if (is_callable($this->available_callable)) {
151  $callable = $this->available_callable;
152 
153  $value = $callable();
154 
155  return $value;
156  }
157 
158  return true;
159  }
160 
161 
165  public function withNonAvailableReason(Legacy $element) : isItem
166  {
167  $clone = clone $this;
168  $clone->non_available_reason = $element;
169 
170  return $clone;
171  }
172 
173 
177  public function getNonAvailableReason() : Legacy
178  {
179  global $DIC;
180 
181  return $this->non_available_reason instanceof Legacy ? $this->non_available_reason : $DIC->ui()->factory()->legacy("");
182  }
183 
184 
188  public function isAlwaysAvailable() : bool
189  {
191  }
192 
193 
197  public function withAlwaysAvailable(bool $always_active) : isItem
198  {
199  $clone = clone($this);
200  $clone->is_always_available = $always_active;
201 
202  return $clone;
203  }
204 
205 
209  public function getPosition() : int
210  {
211  return $this->position;
212  }
213 
214 
218  public function withPosition(int $position) : isItem
219  {
220  $clone = clone($this);
221  $clone->position = $position;
222 
223  return $clone;
224  }
225 
226 
230  public function setTypeInformation(TypeInformation $information) : isItem
231  {
232  $this->type_information = $information;
233 
234  return $this;
235  }
236 
237 
242  {
243  return $this->type_information instanceof TypeInformation ? $this->type_information : new TypeInformation(get_class($this), get_class($this));
244  }
245 }
global $DIC
Definition: saml.php:7
__construct(IdentificationInterface $provider_identification)
AbstractBaseItem constructor.