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

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

Public Member Functions

 __construct (PluginHooksService $hooks, RouteCollection $routes, UrlMatcher $matcher, HandlersService $handlers, ResponseFactory $response, 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 hook. 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...
 

Protected Attributes

 $hooks
 
 $routes
 
 $matcher
 
 $handlers
 
 $response
 
 $plugins
 

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 ( PluginHooksService  $hooks,
RouteCollection  $routes,
UrlMatcher  $matcher,
HandlersService  $handlers,
ResponseFactory  $response,
Plugins  $plugins 
)

Constructor.

Parameters
PluginHooksService$hooksHook service
RouteCollection$routesRoute collection
UrlMatcher$matcherURL Matcher
HandlersService$handlersHandlers service
ResponseFactory$responseResponse
Plugins$pluginsPlugins

Definition at line 70 of file Router.php.

Member Function Documentation

Elgg\Router::allowRewrite ( HttpRequest  $request)

Filter a request through the route:rewrite hook.

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

Definition at line 296 of file Router.php.

Elgg\Router::getResponse ( HttpRequest  $request)

Build a response.

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

Definition at line 120 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 265 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 228 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 145 of file Router.php.

Elgg\Router::route ( HttpRequest  $request)

Routes the request to a registered page handler.

This function triggers a plugin hook `'route', $identifier` 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 96 of file Router.php.

Member Data Documentation

Elgg\Router::$handlers
protected

Definition at line 48 of file Router.php.

Elgg\Router::$hooks
protected

Definition at line 33 of file Router.php.

Elgg\Router::$matcher
protected

Definition at line 43 of file Router.php.

Elgg\Router::$plugins
protected

Definition at line 58 of file Router.php.

Elgg\Router::$response
protected

Definition at line 53 of file Router.php.

Elgg\Router::$routes
protected

Definition at line 38 of file Router.php.


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