Elgg  Version 6.1
Public Member Functions | Protected Member Functions | List of all members
Elgg\Router Class Reference

Delegates requests to controllers based on the registered configuration. More...

Public Member Functions

 __construct (protected EventsService $events, protected RouteCollection $routes, protected UrlMatcher $matcher, protected HandlersService $handlers, protected ResponseFactory $response, protected Plugins $plugins)
 Constructor. More...
 
 route (HttpRequest $request)
 Routes the request to a registered page handler. More...
 
 getResponse (HttpRequest $request)
 Build a response. More...
 
 allowRewrite (HttpRequest $request)
 Filter a request through the 'route:rewrite' event. More...
 

Protected Member Functions

 prepareResponse (HttpRequest $request)
 Prepare response. More...
 
 getResponseFromHandler ($handler,\Elgg\Request $request)
 Get response from handler function. More...
 
 getResponseFromFile (string $file,\Elgg\Request $request)
 Get response from file. More...
 

Detailed Description

Delegates requests to controllers based on the registered configuration.

Plugin devs should use elgg_register_route() to register a named route or define it in elgg-plugin.php

Since
1.9.0

Definition at line 26 of file Router.php.

Constructor & Destructor Documentation

Elgg\Router::__construct ( protected EventsService  $events,
protected RouteCollection  $routes,
protected UrlMatcher  $matcher,
protected HandlersService  $handlers,
protected ResponseFactory  $response,
protected Plugins  $plugins 
)

Constructor.

Parameters
EventsService$eventsEvents service
RouteCollection$routesRoute collection
UrlMatcher$matcherURL Matcher
HandlersService$handlersHandlers service
ResponseFactory$responseResponse
Plugins$pluginsPlugins

Definition at line 40 of file Router.php.

Member Function Documentation

Elgg\Router::allowRewrite ( HttpRequest  $request)

Filter a request through the 'route:rewrite' event.

Parameters
\Elgg\Http\Request$requestElgg request
Returns
Exceptions
RuntimeException

Definition at line 260 of file Router.php.

Elgg\Router::getResponse ( HttpRequest  $request)

Build a response.

Parameters
\Elgg\Http\Request$requestRequest
Returns
ResponseBuilder
Exceptions
PageNotFoundException

Definition at line 84 of file Router.php.

Elgg\Router::getResponseFromFile ( string  $file,
\Elgg\Request  $request 
)
protected

Get response from file.

Parameters
string$fileFile
\Elgg\Request$requestRequest envelope
Returns
ResponseBuilder|null
Exceptions
PageNotFoundException

Definition at line 229 of file Router.php.

Elgg\Router::getResponseFromHandler (   $handler,
\Elgg\Request  $request 
)
protected

Get response from handler function.

Parameters
callable$handlerLegacy page handler function
\Elgg\Request$requestRequest envelope
Returns
ResponseBuilder|null

Definition at line 192 of file Router.php.

Elgg\Router::prepareResponse ( HttpRequest  $request)
protected

Prepare response.

Parameters
\Elgg\Http\Request$requestRequest
Returns
ResponseBuilder|null
Exceptions
BadRequestException
PageNotFoundException

Definition at line 109 of file Router.php.

Elgg\Router::route ( HttpRequest  $request)

Routes the request to a registered page handler.

This function triggers a `'route', $identifier` event so that plugins can modify the routing or handle a request.

Parameters
\Elgg\Http\Request$requestThe request to handle.
Returns
boolean Whether the request was routed successfully.

Definition at line 60 of file Router.php.


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