AbstractController

Base class for custom routes on top of WordPress.

  • Full name: \CEKW\WpPlugin\AbstractController
Table of contents
  1. Properties
  2. Methods
    1. __construct
    2. generateUrl
    3. redirect
    4. redirectToRoute
    5. setTitle
    6. setUrl
    7. render

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