19declare(strict_types=1);
44 private array $handler_instances
48 foreach ($handler_instances as $handler_instance) {
49 if (!$handler_instance instanceof
Handler) {
50 throw new \InvalidArgumentException(
51 'Handler instances must implement the Handler interface'
59 foreach ($this->handler_instances as
$handler) {
60 if (isset($this->handlers[
$handler->getNamespace()])) {
61 throw new \LogicException(
"Namespace-Collision detected: " .
$handler->getNamespace());
65 foreach (
$handler->getNamespaceAliasses() as $namespace_aliass) {
66 if (isset($this->handlers[$namespace_aliass])) {
67 throw new \LogicException(
"Namespace-Collision detected: " . $namespace_aliass);
69 $this->handlers[$namespace_aliass] =
$handler;
80 if (empty($this->handlers)) {
84 $http = $this->context->http();
86 $request = $this->request_builder->buildRequest(
88 $this->context->refinery(),
91 if (!$request instanceof
Request) {
92 throw new \RuntimeException(
'No request could be built');
95 $handler = $this->handlers[$request->getNamespace()] ??
null;
97 throw new \InvalidArgumentException(
'No handler found for namespace ' . $request->getNamespace());
102 $http->response()->withStatus(404),
104 $http->sendResponse();
112 $target = $uri_builder->buildTarget(
113 $request->getNamespace(),
114 $request->getReferenceId(),
115 $request->getAdditionalParameters()
117 $full_uri = $base_uri .
"/login.php?target=";
118 $full_uri .= str_replace(
'/',
'_', rtrim($target,
'/'));
119 if (!$this->context->isUserLoggedIn()) {
120 $full_uri .=
'&cmd=force_login&lang=' . $this->context->getUserLanguage();
125 $this->context->mainTemplate()->setOnScreenMessage(
127 $this->context->lng()->txt(
'permission_denied'),
130 $full_uri = $base_uri .
'/index.php';
134 $uri_path =
$response->getURIPath() ??
'';
135 $base_path = $base_uri->
getPath() ??
'';
136 if ($base_path !==
'' && $base_path !==
'/') {
137 $uri_path = str_replace(rtrim($base_path,
'/') .
'/',
'', $uri_path);
140 for ($x = 0; $x <
$response->shift(); $x++) {
141 $base_uri = $base_uri->
withPath(dirname((
string) $base_uri->
getPath()));
144 $full_uri = $base_uri .
'/' . trim((
string) $uri_path,
'/');
149 $http->response()->withAddedHeader(
'Location', $full_uri)
151 $http->sendResponse();
161 if (
$context->http()->wrapper()->query()->has(
'soap_pw')) {
162 return \ilUtil::appendUrlParameterString(
164 'soap_pw=' .
$context->http()->wrapper()->query()->retrieve(
166 $context->refinery()->kindlyTo()->string()
170 if (
$context->http()->wrapper()->query()->has(
'ext_uid')) {
171 return \ilUtil::appendUrlParameterString(
173 'ext_uid=' .
$context->http()->wrapper()->query()->retrieve(
175 $context->refinery()->kindlyTo()->string()
The scope of this class is split ilias-conform URI's into components.
withPath(?string $path=null)
Get URI with modified path.
appendUnknownParameters(Context $context, string $full_uri)
__construct(private RequestBuilder $request_builder, private Context $context, private array $handler_instances)
Factory $response_factory
performRedirect(URI $base_uri)