ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ContextStack.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use LogicException;
25 
31 {
35  protected array $stack = [];
36 
40  public function push(ScreenContext $context): void
41  {
42  if (in_array($context, $this->stack)) {
43  throw new LogicException("A context can only be claimed once");
44  }
45  $this->stack[] = $context;
46  }
47 
51  public function getLast(): ScreenContext
52  {
53  return end($this->stack);
54  }
55 
59  public function getStack(): array
60  {
61  return $this->stack;
62  }
63 
67  public function getStackAsArray(): array
68  {
69  $return = [];
70  foreach ($this->stack as $item) {
71  $return[] = $item->getUniqueContextIdentifier();
72  }
73 
74  return $return;
75  }
76 }
$context
Definition: webdav.php:31