Elgg
Version master
|
Go to the source code of this file.
Functions | |
elgg_register_route (string $name, array $params=[]) | |
Elgg page handler functions. More... | |
elgg_unregister_route (string $name) | |
Unregister a route by its name. More... | |
elgg_get_route (string $name) | |
Get a registered route by it's name. More... | |
elgg_get_route_for_url (string $url) | |
Find a registered route based on an url/path. More... | |
elgg_get_current_route () | |
Get the route for the current request. More... | |
elgg_get_current_route_name () | |
Get the route name for the current request. More... | |
elgg_route_exists (string $name) | |
Check if a route is registered. More... | |
elgg_get_current_url () | |
Returns the current page's complete URL. More... | |
elgg_generate_url (string $name, array $parameters=[]) | |
Generate a URL for named route. More... | |
elgg_generate_entity_url (ElggEntity $entity, string $resource= 'view', string $subresource=null, array $parameters=[]) | |
Generate entity URL from a named route. More... | |
elgg_generate_action_url (string $action, array $query=[], bool $add_csrf_tokens=true) | |
Generate an action URL. More... | |
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. More... | |
elgg_error_response (string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST) | |
Prepare an error response to be returned by a page or an action handler. More... | |
elgg_redirect_response (string $forward_url=REFERRER, int $status_code=ELGG_HTTP_FOUND, bool $secure_forward_url=true) | |
Prepare a silent redirect response to be returned by a page or an action handler. More... | |
elgg_download_response (string $content, string $filename= '', bool $inline=false, array $headers=[]) | |
Prepare a download response. More... | |
elgg_download_response | ( | string | $content, |
string | $filename = '' , |
||
bool | $inline = false , |
||
array | $headers = [] |
||
) |
Prepare a download response.
string | $content | The content of the download |
string | $filename | The filename when downloaded |
bool | $inline | Is this an inline download (default: false, determines the 'Content-Disposition' header) |
array | $headers | (optional) additional headers for the response |
Definition at line 285 of file pagehandler.php.
elgg_error_response | ( | string|array | $message = '' , |
string | $forward_url = REFERRER , |
||
int | $status_code = ELGG_HTTP_BAD_REQUEST |
||
) |
Prepare an error response to be returned by a page or an action handler.
string | array | $message | Error message Can be used by handlers to display an error message For certain requests this error message will also be used as the response body |
string | $forward_url | URL to redirect the client to Can be used by handlers to redirect the client on non-ajax requests |
int | $status_code | HTTP status code Status code of the HTTP response |
Definition at line 245 of file pagehandler.php.
elgg_generate_action_url | ( | string | $action, |
array | $query = [] , |
||
bool | $add_csrf_tokens = true |
||
) |
Generate an action URL.
string | $action | Action name |
array | $query | Query elements |
bool | $add_csrf_tokens | Add tokens |
Definition at line 197 of file pagehandler.php.
elgg_generate_entity_url | ( | ElggEntity | $entity, |
string | $resource = 'view' , |
||
string | $subresource = null , |
||
array | $parameters = [] |
||
) |
Generate entity URL from a named route.
This function is intended to generate URLs from registered named routes that depend on entity type and subtype. It will first try to detect routes that contain both type and subtype in the name, and will then fallback to route names without the subtype, e.g. 'view:object:blog:attachments' and 'view:object:attachments'
Route segments will be automatically resolved from entity attributes and metadata, so given the path /blog/view/{guid}/{title}/{status}
the path will be be resolved from entity guid, URL-friendly title and status metadata.
Parameters that do not have matching segment names in the route path, will be added to the URL as query elements.
ElggEntity | $entity | Entity |
string | $resource | Resource name |
string | $subresource | Subresource name |
array | $parameters | URL query elements |
Definition at line 159 of file pagehandler.php.
elgg_generate_url | ( | string | $name, |
array | $parameters = [] |
||
) |
Generate a URL for named route.
string | $name | Route name |
array | $parameters | Parameters |
Definition at line 133 of file pagehandler.php.
elgg_get_current_route | ( | ) |
Get the route for the current request.
Definition at line 88 of file pagehandler.php.
elgg_get_current_route_name | ( | ) |
Get the route name for the current request.
Definition at line 98 of file pagehandler.php.
elgg_get_current_url | ( | ) |
Returns the current page's complete URL.
Definition at line 121 of file pagehandler.php.
elgg_get_route | ( | string | $name | ) |
Get a registered route by it's name.
string | $name | the route name |
Definition at line 50 of file pagehandler.php.
elgg_get_route_for_url | ( | string | $url | ) |
Find a registered route based on an url/path.
string | $url | the full url or an url path to find a route for |
Definition at line 62 of file pagehandler.php.
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.
mixed | $content | Response content In page handlers, response content should contain an HTML string In action handlers, response content can contain either a JSON string or an array of data |
string | array | $message | System message visible to the client Can be used by handlers to display a system message |
string | $forward_url | Forward URL Can be used by handlers to redirect the client on non-ajax requests |
int | $status_code | HTTP status code Status code of the HTTP response (defaults to 200) |
Definition at line 224 of file pagehandler.php.
elgg_redirect_response | ( | string | $forward_url = REFERRER , |
int | $status_code = ELGG_HTTP_FOUND , |
||
bool | $secure_forward_url = true |
||
) |
Prepare a silent redirect response to be returned by a page or an action handler.
string | $forward_url | Redirection URL Relative or absolute URL to redirect the client to |
int | $status_code | HTTP status code Status code of the HTTP response Note that the Router and AJAX API will treat these responses as redirection in spite of the HTTP code assigned Note that non-redirection HTTP codes will throw an exception |
bool | $secure_forward_url | Determines if the forward url needs to be secure |
Definition at line 270 of file pagehandler.php.
elgg_register_route | ( | string | $name, |
array | $params = [] |
||
) |
Elgg page handler functions.
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.
string | $name | Unique route name This name can later be used to generate route URLs |
array | $params | Route parameters
|
Definition at line 27 of file pagehandler.php.
elgg_route_exists | ( | string | $name | ) |
Check if a route is registered.
string | $name | route name |
Definition at line 111 of file pagehandler.php.
elgg_unregister_route | ( | string | $name | ) |
Unregister a route by its name.
string | $name | Name of the route |
Definition at line 38 of file pagehandler.php.