ApiTrait
Provides a controller-level `api` settings array, hydrated either from an initialization array or from a PSR-11 container entry.
The settings are exposed through the protected $api property and populated
by self::initializeApi(), so API-related configuration (endpoints,
keys, feature flags, etc.) can be centralized in the DI container and shared
consistently across all controllers.
Tags
Table of Contents
Properties
- $api : array<string|int, mixed>
- The default api settings.
Methods
- initializeApi() : static
- Initializes the internal `api` settings.
Properties
$api
The default api settings.
protected
array<string|int, mixed>
$api
= []
Methods
initializeApi()
Initializes the internal `api` settings.
public
initializeApi([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static
By default, this method search in the DI container a ControllerParam::API definition to initialize the "api" property.
Parameters
- $init : array<string|int, mixed> = []
-
Optional initialization array (e.g., ['api' => [ ... ] ] ).
- $container : ContainerInterface|null = null
-
Optional DI container for retrieving the 'api' array representation.
Tags
Return values
static —Returns the current controller instance for method chaining.