ControllerResolver
final class ControllerResolver (View source)
Route-to-controller dispatcher for HTTP requests.
The resolver obtains controller instances through the dependency injection container, binds the current PSR-7 server request for the dispatch cycle, resolves action parameters from the request and route parameters, performs scalar conversion for builtin parameter types, invokes the controller action, and normalizes the result to a PSR-7 response.
Methods
Accepts the container used for controller resolution, request binding, response factories, stream factories, and benchmark access.
Dispatches the matched controller action and normalizes its result to a PSR-7 response.
Details
__construct
__construct(ContainerInterface $container, Benchmark $benchmark)
Accepts the container used for controller resolution, request binding, response factories, stream factories, and benchmark access.
handle
ResponseInterface
handle(RouteMatch $match, ServerRequestInterface $request)
Dispatches the matched controller action and normalizes its result to a PSR-7 response.
The current request is first bound into the container for this dispatch
cycle. The resolver then reads the controller class, action, and route
parameters from the route match, resolves the controller through the
container, initializes {\Lemonade\Framework\Core\AbstractController} context when applicable,
injects ServerRequestInterface action parameters directly, maps named
route parameters to action arguments, converts builtin int, float,
bool, and string parameters, applies declared default values when
route parameters are absent, invokes the action, and normalizes the
result.
Existing PSR responses are returned unchanged. Scalar, stringable, and
null results are converted to a 200 text/html; charset=UTF-8
response.