ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ContextCollection.php
Go to the documentation of this file.
2
5
12{
13 const C_MAIN = 'main';
14 const C_DESKTOP = 'desktop';
15 const C_REPO = 'repo';
16 const C_ADMINISTRATION = 'administration';
17 const C_MAIL = 'mail';
21 protected $repo;
25 protected $stack = [];
26
27
33 public function __construct(ContextRepository $context_repository)
34 {
35 $this->repo = $context_repository;
36 }
37
38
42 public function push(ScreenContext $context)
43 {
44 array_push($this->stack, $context);
45 }
46
47
51 public function getLast() : ScreenContext
52 {
53 return end($this->stack);
54 }
55
56
60 public function getStack() : array
61 {
62 return $this->stack;
63 }
64
65
69 public function getStackAsArray() : array
70 {
71 $return = [];
72 foreach ($this->stack as $item) {
73 $return[] = $item->getUniqueContextIdentifier();
74 }
75
76 return $return;
77 }
78
79
85 public function hasMatch(ContextCollection $other_collection) : bool
86 {
87 $mapper = function (ScreenContext $c) {
88 return $c->getUniqueContextIdentifier();
89 };
90 $mine = array_map($mapper, $this->getStack());
91 $theirs = array_map($mapper, $other_collection->getStack());
92
93 return (count(array_intersect($mine, $theirs)) > 0);
94 }
95
96 //
97 //
98 //
102 public function main() : ContextCollection
103 {
104 $context = $this->repo->main();
105 $this->push($context);
106
107 return $this;
108 }
109
110
114 public function desktop() : ContextCollection
115 {
116 $this->push($this->repo->desktop());
117
118 return $this;
119 }
120
121
125 public function repository() : ContextCollection
126 {
127 $this->push($this->repo->repository());
128
129 return $this;
130 }
131
132
137 {
138 $this->push($this->repo->administration());
139
140 return $this;
141 }
142
143
147 public function internal() : ContextCollection
148 {
149 $this->push($this->repo->internal());
150
151 return $this;
152 }
153
154
158 public function external() : ContextCollection
159 {
160 $this->push($this->repo->external());
161
162 return $this;
163 }
164
165
169 public function lti() : ContextCollection
170 {
171 $this->push($this->repo->lti());
172 return $this;
173 }
174}
An exception for terminatinating execution or to throw for unit testing.
__construct(ContextRepository $context_repository)
ContextCollection constructor.
$context
Definition: webdav.php:26