ILIAS
trunk Revision v11.0_alpha-1715-g7fc467680fb
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
c
e
g
h
j
l
m
p
s
t
u
v
+
Enumerations
a
c
e
f
i
j
l
m
n
o
p
r
s
t
u
v
z
+
Enumerator
a
c
d
e
f
g
i
l
m
n
o
p
q
s
t
u
v
y
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
Enumerations
Enumerator
+
Files
File List
+
Globals
+
All
$
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
z
+
Functions
a
b
c
d
e
f
g
h
i
m
n
p
r
s
t
u
v
+
Variables
$
a
c
e
g
h
i
m
n
o
p
r
s
t
u
v
z
Enumerations
Enumerator
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Modules
Pages
CalledContexts.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\GlobalScreen\ScreenContext\Stack
;
22
23
use
ILIAS\GlobalScreen\ScreenContext\ScreenContext
;
24
use
LogicException
;
25
29
final
class
CalledContexts
extends
ContextCollection
30
{
31
private
array
$call_locations
= [];
32
33
public
function
current
():
ScreenContext
34
{
35
return
$this->
getLast
();
36
}
37
38
#[\Override]
39
public
function
push
(
ScreenContext
$context
): void
40
{
41
$this->
claim
(
42
$context,
43
$context->
getUniqueContextIdentifier
() ===
'external'
44
);
// external can be claimed multiple times
45
}
46
47
#[\Override]
48
public
function
external
():
ContextCollection
49
{
50
$this->
claim
($this->repo->external(),
true
);
51
52
return
$this
;
53
}
54
55
public
function
clear
(): void
56
{
57
$this->call_locations = [];
58
$this->stack = [];
59
}
60
61
protected
function
claim
(
ScreenContext
$context
,
bool
$silent =
false
): void
62
{
63
$this->
checkCallLocation
($context, $silent);
64
65
if
(!$silent && in_array($context, $this->stack)) {
66
throw
new
LogicException
(
"A context can only be claimed once"
);
67
}
68
parent::push($context);
69
}
70
71
private
function
checkCallLocation
(
ScreenContext
$context
,
bool
$silent =
false
): void
72
{
73
$called_classes = array_filter(
74
debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),
75
function
($item):
bool
{
76
if
(!isset($item[
'class'
])) {
77
return
false
;
78
}
79
80
return
(!in_array($item[
'class'
], [CalledContexts::class, ContextCollection::class]));
81
}
82
);
83
array_walk(
84
$called_classes,
85
function
(& $item):
void
{
86
$item = ($item[
'class'
] ??
''
) .
":"
. ($item[
'line'
] ??
''
);
87
}
88
);
89
90
$call_location = reset($called_classes);
91
92
if
(!$silent && isset($this->call_locations[$context->
getUniqueContextIdentifier
()])) {
93
$first_location = $this->call_locations[$context->
getUniqueContextIdentifier
()];
94
throw
new
LogicException
(
"context '{$context->getUniqueContextIdentifier()}' already claimed in $first_location, second try in $call_location"
);
95
}
96
$this->call_locations[$context->
getUniqueContextIdentifier
()] = $call_location;
97
}
98
}
LogicException
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\$call_locations
array $call_locations
Definition:
CalledContexts.php:31
ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection\$this
function return $this
Definition:
ContextCollection.php:123
$context
$context
Definition:
webdav.php:31
ScreenContext
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\checkCallLocation
checkCallLocation(ScreenContext $context, bool $silent=false)
Definition:
CalledContexts.php:71
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\current
current()
Definition:
CalledContexts.php:33
ILIAS\GlobalScreen\ScreenContext\Stack
Definition:
CalledContexts.php:21
ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection\getLast
getLast()
Definition:
ContextCollection.php:56
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts
Definition:
CalledContexts.php:29
ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection
Definition:
ContextCollection.php:30
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\external
external()
Definition:
CalledContexts.php:48
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\clear
clear()
Definition:
CalledContexts.php:55
ILIAS\GlobalScreen\ScreenContext\ScreenContext\getUniqueContextIdentifier
getUniqueContextIdentifier()
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\claim
claim(ScreenContext $context, bool $silent=false)
Definition:
CalledContexts.php:61
ILIAS\GlobalScreen\ScreenContext\ScreenContext
Interface ScreenContext.
Definition:
ScreenContext.php:29
ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\push
push(ScreenContext $context)
Definition:
CalledContexts.php:39
components
ILIAS
GlobalScreen
src
ScreenContext
Stack
CalledContexts.php
Generated on Sat Apr 5 2025 23:03:18 for ILIAS by
1.8.13 (using
Doxyfile
)