ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ILIAS\StaticURL\Handler\HandlerService Class Reference
+ Collaboration diagram for ILIAS\StaticURL\Handler\HandlerService:

Public Member Functions

 __construct (private RequestBuilder $request_builder, private Context $context, Handler ... $handlers,)
 
 performRedirect (URI $base_uri)
 

Private Member Functions

 appendUnknownParameters (Context $context, string $full_uri)
 

Private Attributes

array $handlers = []
 
Factory $response_factory
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 35 of file HandlerService.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\StaticURL\Handler\HandlerService::__construct ( private RequestBuilder  $request_builder,
private Context  $context,
Handler ...  $handlers 
)

Definition at line 43 of file HandlerService.php.

References $handler.

47  {
48  $this->response_factory = new Factory($context);
49  foreach ($handlers as $handler) {
50  $this->handlers[$handler->getNamespace()] = $handler;
51  }
52  }
$context
Definition: webdav.php:31
$handler
Definition: oai.php:29

Member Function Documentation

◆ appendUnknownParameters()

ILIAS\StaticURL\Handler\HandlerService::appendUnknownParameters ( Context  $context,
string  $full_uri 
)
private
Deprecated:
Thsi piece of code comes from the old goto.php and should be removed as soon as possible.

Or this can be moved to the place where is is needed.

Definition at line 127 of file HandlerService.php.

References ILIAS\StaticURL\Context\http(), and ILIAS\StaticURL\Context\refinery().

Referenced by ILIAS\StaticURL\Handler\HandlerService\performRedirect().

127  : string
128  {
129  if ($context->http()->wrapper()->query()->has('soap_pw')) {
130  return \ilUtil::appendUrlParameterString(
131  $full_uri,
132  'soap_pw=' . $context->http()->wrapper()->query()->retrieve(
133  'soap_pw',
134  $context->refinery()->kindlyTo()->string()
135  )
136  );
137  }
138  if ($context->http()->wrapper()->query()->has('ext_uid')) {
139  return \ilUtil::appendUrlParameterString(
140  $full_uri,
141  'ext_uid=' . $context->http()->wrapper()->query()->retrieve(
142  'ext_uid',
143  $context->refinery()->kindlyTo()->string()
144  )
145  );
146  }
147 
148  return $full_uri;
149  }
$context
Definition: webdav.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performRedirect()

ILIAS\StaticURL\Handler\HandlerService::performRedirect ( URI  $base_uri)
Returns
never

Definition at line 57 of file HandlerService.php.

References $handler, ILIAS\StaticURL\Handler\HandlerService\$handlers, $http, $response, ILIAS\StaticURL\Handler\HandlerService\appendUnknownParameters(), ILIAS\Data\URI\getPath(), and null.

57  : void
58  {
59  $http = $this->context->http();
60 
61  $request = $this->request_builder->buildRequest(
62  $http,
63  $this->context->refinery(),
65  );
66  if (!$request instanceof Request) {
67  throw new \RuntimeException('No request could be built');
68  }
69 
70  $handler = $this->handlers[$request->getNamespace()] ?? null;
71  if (!$handler instanceof Handler) {
72  throw new \InvalidArgumentException('No handler found for namespace ' . $request->getNamespace());
73  }
74  $response = $handler->handle($request, $this->context, $this->response_factory);
75  if (!$response->targetCanBeReached()) {
76  throw new \RuntimeException(
77  'Handler ' . $handler->getNamespace() . ' did not return a URI'
78  ); // TODO: we shoud redirect somewhere
79  }
80 
81  $uri_builder = new StandardURIBuilder(ILIAS_HTTP_PATH, false);
82 
83  switch (true) {
84  case $response instanceof MaybeCanHandlerAfterLogin:
85  $target = $uri_builder->buildTarget(
86  $request->getNamespace(),
87  $request->getReferenceId(),
88  $request->getAdditionalParameters()
89  );
90  $full_uri = $base_uri . "/login.php?target=";
91  $full_uri .= str_replace('/', '_', rtrim($target, '/')); // TODO: ILIAS currently need this like this
92  if (!$this->context->isUserLoggedIn()) {
93  $full_uri .= '&cmd=force_login&lang=' . $this->context->getUserLanguage();
94  }
95  $full_uri = $this->appendUnknownParameters($this->context, $full_uri); // Read the comment below
96  break;
97  case $response instanceof CannotReach:
98  $this->context->mainTemplate()->setOnScreenMessage(
99  'failure',
100  $this->context->lng()->txt('permission_denied'),
101  true
102  );
103  $full_uri = $base_uri . '/index.php';
104  break;
105  default:
106  // Perform Redirect
107  $uri_path = $response->getURIPath() ?? '';
108  $base_path = $base_uri->getPath() ?? '';
109  if ($base_path !== '' && $base_path !== '/') {
110  $uri_path = str_replace(rtrim($base_path, '/') . '/', '', $uri_path);
111  }
112  $full_uri = $base_uri . '/' . trim((string) $uri_path, '/');
113  break;
114  }
115 
116  $http->saveResponse(
117  $http->response()->withAddedHeader('Location', $full_uri)
118  );
119  $http->sendResponse();
120  $http->close();
121  }
$response
Definition: xapitoken.php:93
$http
Definition: deliver.php:30
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$handler
Definition: oai.php:29
appendUnknownParameters(Context $context, string $full_uri)
+ Here is the call graph for this function:

Field Documentation

◆ $handlers

array ILIAS\StaticURL\Handler\HandlerService::$handlers = []
private

◆ $response_factory

Factory ILIAS\StaticURL\Handler\HandlerService::$response_factory
private

Definition at line 41 of file HandlerService.php.


The documentation for this class was generated from the following file: