RestRouteRegistrar
in package
FinalYes
REST routing surface: collects {@see RestControllerInterface} controllers and hands each the per-component namespace on register().
The namespace is derived from the host component — {componentName}/{version}
(default version v1) — instead of a hardcoded brand literal, so two plugins
in the same request expose disjoint /wp-json/{slug}/v1/* roots. The optional
version keeps the escape hatch the old free-form namespace param offered.
Sibling surfaces: AdminRouteRegistrar (wp-admin menus) and PublicRouteRegistrar (front-end rewrite).
Table of Contents
Properties
- $apiNamespace : string
- $container : ContainerInterface
- $controllers : array<string|int, RestControllerInterface>>
Methods
- __construct() : mixed
- addController() : void
- getNamespace() : string
- register() : void
Properties
$apiNamespace read-only
private
string
$apiNamespace
$container read-only
private
ContainerInterface
$container
$controllers
private
array<string|int, RestControllerInterface>>
$controllers
= []
Methods
__construct()
public
__construct(ContainerInterface $container, HostComponentContextInterface $context[, string $apiVersion = 'v1' ]) : mixed
Parameters
- $container : ContainerInterface
- $context : HostComponentContextInterface
- $apiVersion : string = 'v1'
addController()
public
addController(string $controllerClass) : void
Parameters
- $controllerClass : string
getNamespace()
public
getNamespace() : string
Return values
stringregister()
public
register() : void