ILIAS  release_7 Revision v7.30-3-g800a261c036
ContextRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
21
23
33{
37 private $contexts = [];
38 private const C_MAIN = 'main';
39 private const C_DESKTOP = 'desktop';
40 private const C_REPO = 'repo';
41 private const C_ADMINISTRATION = 'administration';
42 private const C_LTI = 'lti';
43
44
48 public function main() : ScreenContext
49 {
50 return $this->get(BasicScreenContext::class, self::C_MAIN);
51 }
52
56 public function internal() : ScreenContext
57 {
58 return $this->get(BasicScreenContext::class, 'internal');
59 }
60
64 public function external() : ScreenContext
65 {
66 return $this->get(BasicScreenContext::class, 'external');
67 }
68
72 public function desktop() : ScreenContext
73 {
74 return $this->get(BasicScreenContext::class, self::C_DESKTOP);
75 }
76
80 public function repository() : ScreenContext
81 {
82 $context = $this->get(BasicScreenContext::class, self::C_REPO);
83 $context = $context->withReferenceId(new ReferenceId((int) ($_GET['ref_id'] ?? 0)));
84
85 return $context;
86 }
87
91 public function administration() : ScreenContext
92 {
93 return $this->get(BasicScreenContext::class, self::C_ADMINISTRATION);
94 }
95
99 public function lti() : ScreenContext
100 {
101 return $this->get(BasicScreenContext::class, self::C_LTI);
102 }
103
104 private function get(string $class_name, string $identifier) : ScreenContext
105 {
106 if (!isset($this->contexts[$identifier])) {
107 $this->contexts[$identifier] = new $class_name($identifier);
108 }
109
110 return $this->contexts[$identifier];
111 }
112}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
$context
Definition: webdav.php:26