ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 34 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 42 of file HandlerService.php.

References $handler.

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

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 115 of file HandlerService.php.

References ilUtil\appendUrlParameterString(), and ILIAS\StaticURL\Context\http().

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

115  : string
116  {
117  if ($context->http()->wrapper()->query()->has('soap_pw')) {
118  return \ilUtil::appendUrlParameterString(
119  $full_uri,
120  'soap_pw=' . $context->http()->wrapper()->query()->retrieve(
121  'soap_pw',
122  $context->refineryttp()->kindlyTo()->string()
123  )
124  );
125  }
126  if ($context->http()->wrapper()->query()->has('ext_uid')) {
128  $full_uri,
129  'ext_uid=' . $context->http()->wrapper()->query()->retrieve(
130  'ext_uid',
131  $context->refineryttp()->kindlyTo()->string()
132  )
133  );
134  }
135 
136  return $full_uri;
137  }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
$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 56 of file HandlerService.php.

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

56  : void
57  {
58  $http = $this->context->http();
59  $ctrl = $this->context->refinery();
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  // Check access to target
82  if (
83  $response instanceof MaybeCanHandlerAfterLogin
84  || (!$this->context->isUserLoggedIn() && !$this->context->isPublicSectionActive())
85  ) {
86  $uri_builder = new StandardURIBuilder(ILIAS_HTTP_PATH, false);
87  $target = $uri_builder->buildTarget(
88  $request->getNamespace(),
89  $request->getReferenceId(),
90  $request->getAdditionalParameters()
91  );
92  $full_uri = $base_uri . "/login.php?target=";
93  $full_uri .= str_replace('/', '_', rtrim($target, '/')); // TODO: ILIAS currently need this like this
94  $full_uri .= '&cmd=force_login&lang=' . $this->context->getUserLanguage();
95  $full_uri = $this->appendUnknownParameters($this->context, $full_uri); // Read the comment below
96  } else {
97  // Perform Redirect
98  $uri_path = $response->getURIPath() ?? '';
99  $base_path = $base_uri->getPath() ?? '';
100  $uri_path = str_replace($base_path, '', $uri_path);
101  $full_uri = $base_uri . '/' . trim((string) $uri_path, '/');
102  }
103 
104  $http->saveResponse(
105  $http->response()->withAddedHeader('Location', $full_uri)
106  );
107  $http->sendResponse();
108  $http->close();
109  }
$response
Definition: xapitoken.php:93
$http
Definition: deliver.php:30
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$handler
Definition: oai.php:30
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 40 of file HandlerService.php.


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