WooCommerce Code Reference

RoutesController
in package

RoutesController class.

Table of Contents

$routes  : array<string|int, mixed>
Stores routes.
$schema_controller  : SchemaController
Stores schema_controller.
$api_namespace  : string
Namespace for the API.
__construct()  : mixed
Constructor.
get()  : AbstractRoute
Get a route class instance.
get_all_routes()  : array<string|int, string>
Get a route path without instantiating the corresponding RoutesController object.
register_all_routes()  : mixed
Register all Store API routes. This includes routes under specific version namespaces.
register_routes()  : mixed
Register defined list of routes with WordPress.

Properties

Methods

get()

Get a route class instance.

public get(string $name[, string $version = 'v1' ]) : AbstractRoute

Each route class is instantized with the SchemaController instance, and its main Schema Type.

Parameters
$name : string

Name of schema.

$version : string = 'v1'

API Version being requested.

Tags
throws
Exception

If the schema does not exist.

Return values
AbstractRoute

get_all_routes()

Get a route path without instantiating the corresponding RoutesController object.

public get_all_routes([string $version = 'v1' ][, string $controller = false ]) : array<string|int, string>
Parameters
$version : string = 'v1'

API Version being requested.

$controller : string = false

Whether to return controller name. If false, returns empty array. Note: When $controller param is true, the output should not be used directly in front-end code, to prevent class names from leaking. It's not a security issue necessarily, but it's not a good practice. When $controller param is false, it currently returns and empty array. But it can be modified in future to return include more details about the route info that can be used in frontend.

Tags
throws
Exception

If the schema does not exist.

Return values
array<string|int, string>List of route paths.

register_all_routes()

Register all Store API routes. This includes routes under specific version namespaces.

public register_all_routes() : mixed
Return values
mixed

register_routes()

Register defined list of routes with WordPress.

protected register_routes([string $version = 'v1' ][, string $namespace = 'wc/store/v1' ]) : mixed
Parameters
$version : string = 'v1'

API Version being registered..

$namespace : string = 'wc/store/v1'

Overrides the default route namespace.

Return values
mixed