ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
StaticURLRequestBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
31{
32 public function buildRequest(Services $http, Factory $refinery, array $handlers): ?Request
33 {
34 // maybe we have a legacy parameter during transition phase
35 $target = $http->wrapper()->query()->has("target")
36 ? $http->wrapper()->query()->retrieve(
37 "target",
38 $refinery->to()->string()
39 )
40 : null;
41 if ($target !== null) {
42 $target_parts = explode('_', (string) $target);
43 $namespace = array_shift($target_parts);
44
45 $reference_id = is_numeric($target_parts[0] ?? null)
46 ? new ReferenceId((int) array_shift($target_parts))
47 : null;
48 $additional_parameters = [];
49 foreach ($target_parts as $target_part) {
50 $additional_parameters[] = urldecode($target_part);
51 }
52 return new Request(
54 $reference_id,
55 $additional_parameters
56 );
57 }
58
59 // This part is for new urls
60 // everything behind goto.php/ is the requested target
61 $requested_url = (string) $http->request()->getUri();
62
63 if (str_contains($requested_url, '/go/')) {
64 $offset = strpos($requested_url, '/go/') + strlen('/go/');
65 } else {
66 $offset = strpos($requested_url, '/goto.php/') + strlen('/goto.php/');
67 }
68
69 $requested_url = substr(
71 $offset
72 );
73 $requested_url_parts = explode('/', $requested_url);
74 $namespace = array_shift($requested_url_parts);
75 $additional_parameters = [];
76 if (isset($requested_url_parts[0]) && is_numeric($requested_url_parts[0])) {
77 $reference_id = new ReferenceId((int) array_shift($requested_url_parts));
78 } else {
79 $reference_id = null;
80 }
81 foreach ($requested_url_parts as $requested_url_part) {
82 $additional_parameters[] = urldecode($requested_url_part);
83 }
84
85 return new Request(
87 $reference_id,
88 $additional_parameters
89 );
90 }
91}
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
buildRequest(Services $http, Factory $refinery, array $handlers)
$http
Definition: deliver.php:30
$requested_url
Definition: deliver.php:32
if($err=$client->getError()) $namespace