getController.php
Table of Contents
Functions
- getController() : Controller|null
- Retrieves a controller instance from a PSR-11 container if available.
Functions
getController()
Retrieves a controller instance from a PSR-11 container if available.
getController([array<string|int, mixed>|string|null|Controller $definition = null ][, ContainerInterface|null $container = null ][, Controller|null $default = null ]) : Controller|null
This function attempts to fetch a controller by its identifier ($id
)
from the given container. If the container is provided and contains the
specified entry, it is resolved and returned if it is an instance of
Controller. Otherwise, the optional $default
controller is returned.
Parameters
- $definition : array<string|int, mixed>|string|null|Controller = null
-
The controller definition within the container.
- $container : ContainerInterface|null = null
-
The PSR-11 container to fetch the controller from (optional).
- $default : Controller|null = null
-
A fallback controller to return if the container does not provide one (optional).
Tags
Return values
Controller|null —The resolved controller instance or the provided default value, or null
if none found.