ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
AbstractBaseItem.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 use Closure;
31 
35 abstract class AbstractBaseItem implements isItem, isDecorateable
36 {
39 
40  protected int $position = 0;
41  protected ?Closure $active_callable = null;
42  protected bool $is_always_available = false;
44  protected ?Legacy $non_available_reason = null;
45 
50  public function __construct(protected IdentificationInterface $provider_identification)
51  {
52  }
53 
58  {
59  return $this->provider_identification;
60  }
61 
62  public function withNonAvailableReason(Legacy $element): isItem
63  {
64  $clone = clone $this;
65  $clone->non_available_reason = $element;
66 
67  return $clone;
68  }
69 
73  public function getNonAvailableReason(): Legacy
74  {
75  global $DIC;
76 
77  return $this->non_available_reason instanceof Legacy ? $this->non_available_reason : $DIC->ui()->factory()->legacy("");
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 }
withNonAvailableReason(Legacy $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:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...