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

Route registration service. More...

Public Member Functions

 __construct (PluginHooksService $hooks, RouteCollection $routes, UrlGenerator $generator)
 Constructor. More...
 
 register ($name, array $params=[])
 Register a new route. More...
 
 unregister ($name)
 Unregister a route by its name. More...
 
 get ($name)
 Get route config from its name. More...
 
 all ()
 Get all registered routes. More...
 
 generateUrl ($name, array $parameters=[])
 Generate a absolute URL for a named route. More...
 
 resolveRouteParameters ($name,\ElggEntity $entity=null, array $parameters=[])
 Populates route parameters from entity properties. More...
 

Protected Attributes

 $hooks
 
 $routes
 
 $generator
 

Detailed Description

Route registration service.

Definition at line 16 of file RouteRegistrationService.php.

Constructor & Destructor Documentation

Elgg\Router\RouteRegistrationService::__construct ( PluginHooksService  $hooks,
RouteCollection  $routes,
UrlGenerator  $generator 
)

Constructor.

Parameters
PluginHooksService$hooksHook service
RouteCollection$routesRoute collection
UrlGenerator$generatorURL Generator

Definition at line 42 of file RouteRegistrationService.php.

Member Function Documentation

Elgg\Router\RouteRegistrationService::all ( )

Get all registered routes.

Returns
Route[]

Definition at line 188 of file RouteRegistrationService.php.

Elgg\Router\RouteRegistrationService::generateUrl (   $name,
array  $parameters = [] 
)

Generate a absolute URL for a named route.

Parameters
string$nameRoute name
array$parametersQuery parameters
Returns
false|string

Definition at line 200 of file RouteRegistrationService.php.

Elgg\Router\RouteRegistrationService::get (   $name)

Get route config from its name.

Parameters
string$nameRoute name
Returns
Route|null

Definition at line 180 of file RouteRegistrationService.php.

Elgg\Router\RouteRegistrationService::register (   $name,
array  $params = [] 
)

Register a new route.

Route paths can contain wildcard segments, i.e. /blog/owner/{username} To make a certain wildcard segment optional, add ? to its name, i.e. /blog/owner/{username?}

Wildcard requirements for common named variables such as 'guid' and 'username' will be set automatically.

Parameters
string$nameUnique route name This name can later be used to generate route URLs
array$paramsRoute parameters
  • path : path of the route
  • resource : name of the resource view
  • defaults : default values of wildcard segments
  • requirements : regex patterns for wildcard segment requirements
  • methods : HTTP methods
Returns
Route
Exceptions
InvalidParameterException

Definition at line 74 of file RouteRegistrationService.php.

Elgg\Router\RouteRegistrationService::resolveRouteParameters (   $name,
\ElggEntity  $entity = null,
array  $parameters = [] 
)

Populates route parameters from entity properties.

Parameters
string$nameRoute name
\ElggEntity | null$entityEntity
array$parametersPreset parameters
Returns
array|false

Definition at line 230 of file RouteRegistrationService.php.

Elgg\Router\RouteRegistrationService::unregister (   $name)

Unregister a route by its name.

Parameters
string$nameName of the route
Returns
void

Definition at line 169 of file RouteRegistrationService.php.

Member Data Documentation

Elgg\Router\RouteRegistrationService::$generator
protected

Definition at line 33 of file RouteRegistrationService.php.

Elgg\Router\RouteRegistrationService::$hooks
protected

Definition at line 23 of file RouteRegistrationService.php.

Elgg\Router\RouteRegistrationService::$routes
protected

Definition at line 28 of file RouteRegistrationService.php.


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