19declare(strict_types=1);
46 private array $handler_instances,
49 $this->response_factory =
new Factory($context);
51 foreach ($handler_instances as $handler_instance) {
52 if (!$handler_instance instanceof
Handler) {
53 throw new \InvalidArgumentException(
54 'Handler instances must implement the Handler interface'
62 foreach ($this->handler_instances as
$handler) {
63 if (isset($this->handlers[
$handler->getNamespace()])) {
64 throw new \LogicException(
"Namespace-Collision detected: " .
$handler->getNamespace());
68 foreach (
$handler->getNamespaceAliasses() as $namespace_aliass) {
69 if (isset($this->handlers[$namespace_aliass])) {
70 throw new \LogicException(
"Namespace-Collision detected: " . $namespace_aliass);
72 $this->handlers[$namespace_aliass] =
$handler;
83 if (empty($this->handlers)) {
87 $http = $this->context->http();
89 $request = $this->request_builder->buildRequest(
91 $this->context->refinery(),
94 if (!$request instanceof
Request) {
95 throw new \RuntimeException(
'No request could be built');
98 $handler = $this->handlers[$request->getNamespace()] ??
null;
100 throw new \InvalidArgumentException(
'No handler found for namespace ' . $request->getNamespace());
106 $http->response()->withStatus(404),
108 $http->sendResponse();
116 $target = $uri_builder->buildTarget(
117 $request->getNamespace(),
118 $request->getReferenceId(),
119 $request->getAdditionalParameters()
121 $full_uri = $base_uri .
"/login.php?target=";
122 $full_uri .= str_replace(
'/',
'_', rtrim($target,
'/'));
123 if (!$this->context->isUserLoggedIn()) {
124 $full_uri .=
'&cmd=force_login&lang=' . $this->context->getUserLanguage();
133 $uri_path =
$response->getURIPath() ??
'';
134 $base_path = $base_uri->
getPath() ??
'';
135 if ($base_path !==
'' && $base_path !==
'/') {
136 $uri_path = str_replace(rtrim($base_path,
'/') .
'/',
'', $uri_path);
139 for ($x = 0; $x <
$response->shift(); $x++) {
140 $base_uri = $base_uri->
withPath(dirname((
string) $base_uri->
getPath()));
143 $full_uri = $base_uri .
'/' . trim((
string) $uri_path,
'/');
148 $http->response()->withAddedHeader(
'Location', $full_uri)
150 $http->sendResponse();
169 $fallback_ref_id = $target_ref_id > 0
170 ? $this->context->findFirstAccessibleParentRefId($target_ref_id)
173 if ($fallback_ref_id !==
null) {
174 $this->session_store->set(
176 'goto.php?target=' . $request->
getNamespace() .
'_' . $target_ref_id
178 $this->context->mainTemplate()->setOnScreenMessage(
180 $this->context->lng()->txt(
'reg_goto_parent_membership_info'),
183 return $base_uri .
'/ilias.php?baseClass=ilRepositoryGUI&ref_id=' . $fallback_ref_id;
186 $this->context->mainTemplate()->setOnScreenMessage(
188 $this->context->lng()->txt(
'permission_denied'),
201 if ($context->
http()->wrapper()->query()->has(
'soap_pw')) {
202 return \ilUtil::appendUrlParameterString(
204 'soap_pw=' . $context->
http()->wrapper()->query()->retrieve(
206 $context->
refinery()->kindlyTo()->string()
210 if ($context->
http()->wrapper()->query()->has(
'ext_uid')) {
211 return \ilUtil::appendUrlParameterString(
213 'ext_uid=' . $context->
http()->wrapper()->query()->retrieve(
215 $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.
__construct(private RequestBuilder $request_builder, private Context $context, private array $handler_instances, private SessionStore $session_store)
appendUnknownParameters(Context $context, string $full_uri)
buildCannotReachRedirect(URI $base_uri, Request $request)
Builds the redirect target for a {.
Factory $response_factory
performRedirect(URI $base_uri)
Returned by a Handler when it cannot process the given Request at all, e.g.
Returned by a Handler when the target exists but the CURRENT (logged-in) user has no permission to re...
Returned when the target is (or might be) reachable after the user logs in.
static getStartingPointAsUrl()