AbstractController
Base class for custom routes on top of WordPress.
- Full name:
\CEKW\WpPlugin\AbstractController
Table of contents
Properties
Name | Type | Description |
---|---|---|
templatePath | string | Path to the templates directory for public templates. |
config | \CEKW\WpPlugin\Config | Holds the plugin directory path, URL and basename. |
urlGenerator | \Symfony\Component\Routing\Generator\UrlGenerator | Â |
Methods
__construct
AbstractController::__construct(\CEKW\WpPlugin\Config config, \Symfony\Component\Routing\Generator\UrlGenerator urlGenerator)
Parameters:
Parameter | Type | Description |
---|---|---|
config | \CEKW\WpPlugin\Config | Â |
urlGenerator | \Symfony\Component\Routing\Generator\UrlGenerator | Â |
generateUrl
Generates a URL from the given parameters.
AbstractController::generateUrl(string routeName, array params = []): string
Parameters:
Parameter | Type | Description |
---|---|---|
routeName | string | Â |
params | array | Â |
Returns: string
See:
\Symfony\Component\Routing\Generator\UrlGenerator
redirect
Performs a wp_redirect
to the given URL.
AbstractController::redirect(string url, int status = 302): void
Parameters:
Parameter | Type | Description |
---|---|---|
url | string | Â |
status | int | The HTTP status code (302 by default). |
Returns: void
redirectToRoute
Performs a wp_redirect
to the given route with the given parameters.
AbstractController::redirectToRoute(string routeName, array params = [], int status = 302): void
Parameters:
Parameter | Type | Description |
---|---|---|
routeName | string | Â |
params | array | Â |
status | int | The HTTP status code (302 by default). |
Returns: void
setTitle
Sets part of the document title.
AbstractController::setTitle(string title): void
Parameters:
Parameter | Type | Description |
---|---|---|
title | string | Â |
Returns: void
setUrl
Sets the canonical URL for the current route.
AbstractController::setUrl(string url): void
Parameters:
Parameter | Type | Description |
---|---|---|
url | string | Â |
Returns: void
render
Injects template into WordPress.
AbstractController::render(string template, array params = []): void
Parameters:
Parameter | Type | Description |
---|---|---|
template | string | Path to a template file. |
params | array | Â |
Returns: void