ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AbstractBaseItem.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use Closure;
30
34abstract class AbstractBaseItem implements isItem, isDecorateable
35{
38
39 protected int $position = 0;
40 protected ?Closure $active_callable = null;
41 protected bool $is_always_available = false;
43 protected ?Content $non_available_reason = null;
44
49 public function __construct(protected IdentificationInterface $provider_identification)
50 {
51 }
52
57 {
58 return $this->provider_identification;
59 }
60
61 public function withNonAvailableReason(Content|string $element): isItem
62 {
63 if (is_string($element)) {
64 global $DIC;
65 $element = $DIC->ui()->factory()->legacy()->content($element);
66 }
67
68 $clone = clone $this;
69 $clone->non_available_reason = $element;
70
71 return $clone;
72 }
73
77 public function getNonAvailableReason(): Content
78 {
79 global $DIC;
80
81 return $this->non_available_reason instanceof Content ? $this->non_available_reason : $DIC->ui()->factory()->legacy()->content("");
82 }
83
87 public function isAlwaysAvailable(): bool
88 {
90 }
91
95 public function withAlwaysAvailable(bool $always_active): isItem
96 {
97 $clone = clone($this);
98 $clone->is_always_available = $always_active;
99
100 return $clone;
101 }
102
106 public function getPosition(): int
107 {
108 return $this->position;
109 }
110
114 public function withPosition(int $position): isItem
115 {
116 $clone = clone($this);
117 $clone->position = $position;
118
119 return $clone;
120 }
121
125 public function setTypeInformation(TypeInformation $information): isItem
126 {
127 $this->type_information = $information;
128
129 return $this;
130 }
131
136 {
138 }
139
140 public function isTop(): bool
141 {
142 if ($this instanceof isInterchangeableItem) {
143 $changed = $this->hasChanged();
144 if ($this instanceof isChild) {
145 return $changed;
146 }
147 if ($this instanceof isTopItem) {
148 return !$changed;
149 }
150 }
151
152 return $this instanceof isTopItem;
153 }
154}
setTypeInformation(TypeInformation $information)
@inheritDoc
withNonAvailableReason(Content|string $element)
If your provider or the service which provides the Item does not allow to activate the item (.
__construct(protected IdentificationInterface $provider_identification)
AbstractBaseItem constructor.
global $DIC
Definition: shib_login.php:26