ILIAS  release_7 Revision v7.30-3-g800a261c036
ContextStack.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
21
23use LogicException;
24
30{
34 protected $stack = [];
35
39 public function push(ScreenContext $context) : void
40 {
41 if (in_array($context, $this->stack)) {
42 throw new LogicException("A context can only be claimed once");
43 }
44 $this->stack[] = $context;
45 }
46
50 public function getLast() : ScreenContext
51 {
52 return end($this->stack);
53 }
54
58 public function getStack() : array
59 {
60 return $this->stack;
61 }
62
66 public function getStackAsArray() : array
67 {
68 $return = [];
69 foreach ($this->stack as $item) {
70 $return[] = $item->getUniqueContextIdentifier();
71 }
72
73 return $return;
74 }
75}
An exception for terminatinating execution or to throw for unit testing.
$context
Definition: webdav.php:26