ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
AbstractBaseItem.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use Closure;
28
32abstract class AbstractBaseItem implements isItem
33{
35
36 protected int $position = 0;
37 protected ?Closure $active_callable = null;
38 protected bool $is_always_available = false;
40 protected ?Content $non_available_reason = null;
41
45 public function __construct(protected IdentificationInterface $provider_identification)
46 {
47 }
48
53 {
54 return $this->provider_identification;
55 }
56
57 public function withNonAvailableReason(Content|string $element): isItem
58 {
59 if (is_string($element)) {
60 global $DIC;
61 $element = $DIC->ui()->factory()->legacy()->content($element);
62 }
63
64 $clone = clone $this;
65 $clone->non_available_reason = $element;
66
67 return $clone;
68 }
69
73 public function getNonAvailableReason(): Content
74 {
75 global $DIC;
76
77 return $this->non_available_reason instanceof Content ? $this->non_available_reason : $DIC->ui()->factory()->legacy()->content("");
78 }
79
83 public function isAlwaysAvailable(): bool
84 {
86 }
87
91 public function withAlwaysAvailable(bool $always_active): isItem
92 {
93 $clone = clone($this);
94 $clone->is_always_available = $always_active;
95
96 return $clone;
97 }
98
102 public function getPosition(): int
103 {
104 return $this->position;
105 }
106
110 public function withPosition(int $position): isItem
111 {
112 $clone = clone($this);
113 $clone->position = $position;
114
115 return $clone;
116 }
117
121 public function setTypeInformation(TypeInformation $information): isItem
122 {
123 $this->type_information = $information;
124
125 return $this;
126 }
127
132 {
134 }
135
136 public function isTop(): bool
137 {
138 if ($this instanceof isInterchangeableItem) {
139 $changed = $this->hasChanged();
140 if ($this instanceof isChild) {
141 return $changed;
142 }
143 if ($this instanceof isTopItem) {
144 return !$changed;
145 }
146 }
147
148 return $this instanceof isTopItem;
149 }
150}
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