ILIAS  release_8 Revision v8.24
ContextRepository.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
21
26
35{
36 private array $contexts = [];
37 private const C_MAIN = 'main';
38 private const C_DESKTOP = 'desktop';
39 private const C_REPO = 'repo';
40 private const C_ADMINISTRATION = 'administration';
41 private const C_LTI = 'lti';
42
44 protected Factory $refinery;
45
46 public function __construct()
47 {
48 global $DIC;
49 $this->wrapper = $DIC->http()->wrapper();
50 $this->refinery = $DIC->refinery();
51 }
52
56 public function main(): ScreenContext
57 {
58 return $this->get(BasicScreenContext::class, self::C_MAIN);
59 }
60
64 public function internal(): ScreenContext
65 {
66 return $this->get(BasicScreenContext::class, 'internal');
67 }
68
72 public function external(): ScreenContext
73 {
74 return $this->get(BasicScreenContext::class, 'external');
75 }
76
80 public function desktop(): ScreenContext
81 {
82 return $this->get(BasicScreenContext::class, self::C_DESKTOP);
83 }
84
88 public function repository(): ScreenContext
89 {
90 $context = $this->get(BasicScreenContext::class, self::C_REPO);
91 $ref_id = $this->wrapper->query()->has('ref_id')
92 ? $this->wrapper->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int())
93 : 0;
94 $context = $context->withReferenceId(new ReferenceId($ref_id));
95
96 return $context;
97 }
98
102 public function administration(): ScreenContext
103 {
104 return $this->get(BasicScreenContext::class, self::C_ADMINISTRATION);
105 }
106
110 public function lti(): ScreenContext
111 {
112 return $this->get(BasicScreenContext::class, self::C_LTI);
113 }
114
115 private function get(string $class_name, string $identifier): ScreenContext
116 {
117 if (!isset($this->contexts[$identifier])) {
118 $this->contexts[$identifier] = new $class_name($identifier);
119 }
120
121 return $this->contexts[$identifier];
122 }
123}
Builds data types.
Definition: Factory.php:21
Class ContextRepository The Collection of all available Contexts in the System.
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$context
Definition: webdav.php:29