78 $this->events = $events;
79 $this->routes = $routes;
80 $this->matcher = $matcher;
81 $this->handlers = $handlers;
101 $response = $this->getResponse($request);
103 if ($this->response->getSentResponse()) {
109 return headers_sent();
121 $response = $this->prepareResponse($request);
127 if ($request->getFirstUrlSegment() ==
'action') {
128 if (
$response->getForwardURL() === null) {
151 $parameters = $this->matcher->match(
$path);
154 unset($parameters[
'_resource']);
157 unset($parameters[
'_handler']);
160 unset($parameters[
'_controller']);
163 unset($parameters[
'_file']);
165 $deprecated =
elgg_extract(
'_deprecated', $parameters,
'');
166 unset($parameters[
'_deprecated']);
168 $middleware =
elgg_extract(
'_middleware', $parameters, []);
169 unset($parameters[
'_middleware']);
171 $required_plugins = (array)
elgg_extract(
'_required_plugins', $parameters, []);
172 unset($parameters[
'_required_plugins']);
174 unset($parameters[
'_detect_page_owner']);
177 if (!$this->plugins->isActive($plugin_id)) {
182 $route = $this->routes->get($parameters[
'_route']);
183 $route->setMatchedParameters($parameters);
184 $request->setRoute($route);
186 $envelope = new \Elgg\Request(
elgg(), $request);
187 $parameters[
'request'] = $envelope;
189 if (!empty($deprecated)) {
193 foreach ($middleware as $callable) {
194 $result = $this->handlers->call($callable, $envelope, null);
201 return $this->getResponseFromHandler(
$handler, $envelope);
203 $result = $this->handlers->call($controller, $envelope, null);
208 return $this->getResponseFromFile($file, $envelope);
213 }
catch (ResourceNotFoundException $ex) {
215 }
catch (MethodNotAllowedException $ex) {
235 $identifier = array_shift($segments) ?:
'';
266 if (!is_file($file)) {
305 'identifier' => $identifier,
308 $new = $this->events->triggerResults(
'route:rewrite', $identifier, $old, $old);
313 if (!isset($new[
'identifier']) ||
314 !isset($new[
'segments']) ||
315 !is_string($new[
'identifier']) ||
316 !is_array($new[
'segments'])
318 throw new RuntimeException(
'rewrite_path handler returned invalid route data.');
323 array_unshift(
$segments, $new[
'identifier']);
325 return $request->setUrlSegments(
$segments);
trait Profilable
Make an object accept a timer.
HTTP response builder interface.
route(HttpRequest $request)
Routes the request to a registered page handler.
Exception thrown if an error which can only be found on runtime occurs.
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
const ELGG_HTTP_NOT_IMPLEMENTED
Helpers for providing callable-based APIs.
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
prepareResponse(HttpRequest $request)
Prepare response.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Delegates requests to controllers based on the registered configuration.
elgg_view_resource(string $name, array $vars=[])
Render a resource view.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
$plugin_id
Remove all user and plugin settings from the give plugin ID.
__construct(EventsService $events, RouteCollection $routes, UrlMatcher $matcher, HandlersService $handlers, ResponseFactory $response, Plugins $plugins)
Constructor.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
getResponseFromHandler($handler,\Elgg\Request $request)
Get response from handler function.
Thrown when page is not accessible.
const REFERRER
Used in calls to forward() to specify the browser should be redirected to the referring page...
allowRewrite(HttpRequest $request)
Filter a request through the 'route:rewrite' event.
Thrown when request is malformatted.
beginTimer(array $keys)
Start the timer (when enabled)
Persistent, installation-wide key-value storage.
getResponse(HttpRequest $request)
Build a response.
getResponseFromFile(string $file,\Elgg\Request $request)
Get response from file.