PHP Class Elgg\Router

Plugin devs should use these wrapper functions: * elgg_register_page_handler * elgg_unregister_page_handler
Since: 1.9.0
Show file Open project: elgg/elgg Class Usage Examples

Public Methods

Method Description
__construct ( PluginHooksService $hooks ) Constructor
allowRewrite ( Request $request ) : Request Filter a request through the route:rewrite hook
getPageHandlers ( ) : array Get page handlers as array of identifier => callback
registerPageHandler ( string $identifier, string $function ) : boolean Register a function that gets called when the first part of a URL is equal to the identifier.
route ( Request $request ) : boolean Routes the request to a registered page handler
unregisterPageHandler ( string $identifier ) : void Unregister a page handler for an identifier

Method Details

__construct() public method

Constructor
public __construct ( PluginHooksService $hooks )
$hooks PluginHooksService For customized routing.

allowRewrite() public method

Filter a request through the route:rewrite hook
public allowRewrite ( Request $request ) : Request
$request Elgg\Http\Request Elgg request
return Elgg\Http\Request

getPageHandlers() public method

Get page handlers as array of identifier => callback
public getPageHandlers ( ) : array
return array

registerPageHandler() public method

Register a function that gets called when the first part of a URL is equal to the identifier.
public registerPageHandler ( string $identifier, string $function ) : boolean
$identifier string The page type to handle
$function string Your function name
return boolean Depending on success

route() public method

This function triggers a plugin hook 'route', $identifier so that plugins can modify the routing or handle a request.
public route ( Request $request ) : boolean
$request Elgg\Http\Request The request to handle.
return boolean Whether the request was routed successfully.

unregisterPageHandler() public method

Unregister a page handler for an identifier
public unregisterPageHandler ( string $identifier ) : void
$identifier string The page type identifier
return void