19declare(strict_types=1);
61 $this->raw =
new ArrayObject();
67 return function (
isItem $item_one,
isItem $item_two) :
int {
68 return $item_one->
getPosition() - $item_two->getPosition();
78 if (0 < strlen($serialize)) {
79 $this->raw[$serialize] = $item;
88 foreach ($items as $item) {
99 if ($this->raw->offsetExists($identification->serialize())) {
100 $item = $this->raw->offsetGet($identification->serialize());
102 return $item ?? $this->
getLostItem($identification);
115 if ($this->filtered->offsetExists($identification->serialize())) {
116 $item = $this->filtered->offsetGet($identification->serialize());
119 return $item ?? $this->
getLostItem($identification);
127 $this->raw->offsetUnset($identification->serialize());
138 return $this->filtered->offsetExists($identification->serialize());
141 public function has() : bool
143 return $this->raw->count() > 0;
149 if (!isset($this->filtered)) {
150 $this->filtered =
new ArrayObject($this->raw->getArrayCopy());
152 if (count($this->filters) > 0) {
153 if (!isset($this->filtered)) {
154 $filter_copy = $this->raw->getArrayCopy();
156 $filter_copy = $this->filtered->getArrayCopy();
158 foreach ($this->filters as $filter) {
159 $filter_copy = array_filter($filter_copy, $filter ??
function ($v, $k) :
bool {
161 }, $filter ===
null ? ARRAY_FILTER_USE_BOTH : 0);
163 $this->filtered->exchangeArray($filter_copy);
192 $to_walk = (array) $this->filtered->getArrayCopy();
193 array_walk($to_walk,
$c);
194 $this->filtered =
new ArrayObject($to_walk);
202 $this->filters[] =
$c;
209 $this->filtered->uasort($this->
getSorter());
211 $replace_children_sorted =
function (
isItem &$item) {
213 $children = $item->getChildren();
215 $item = $item->withChildren($children);
218 $this->
walk($replace_children_sorted);
225 ->withVisibilityCallable(
229 )->withTitle(
'Lost');
An exception for terminatinating execution or to throw for unit testing.
Class NullIdentification.
getSingleItemFromRaw(IdentificationInterface $identification)
filter(Closure $c)
@inheritDoc
__construct(MainMenuItemFactory $factory)
Tree constructor.
getSingleItemFromFilter(IdentificationInterface $identification)
existsInFilter(IdentificationInterface $identification)
getLostItem(IdentificationInterface $identification)
walk(Closure $c)
@inheritDoc
addMultiple(isItem ... $items)
withAlwaysAvailable(bool $always_active)
@inheritDoc
Class MainMenuItemFactory This factory provides you all available types for MainMenu GlobalScreen Ite...
Interface IdentificationInterface.
getPosition()
Return the default position for installation, this will be overridden by the configuration later.
getProviderIdentification()