final class ControllerEnvironment (View source)

The collaborators a controller is built from. In production Kernel::controllerEnvironment() derives one from the booted context (config file check, database connection, session authentication); a test passes one straight to the constructor with stubbed services, most usefully a stub ControllerServiceFactory, which the create*() accessors on BaseController all route through. Both paths construct the controller the same way.

The request carries the method and the query and post parameters the controller reads (isPost(), the request helpers); without one the controller snapshots the superglobals as it does in production. The page output receives every rendered template with its parameters, so a test can observe pages instead of subclassing render(); without one the themed PageRenderer is built.

The session is the store every collaborator reads and writes; without one the controller works on PHP's own session as it does in production.

Methods

__construct(ConfigurationInterface $config, PDO $db, LoggerInterface $logger, ModuleRegistry $moduleRegistry, ControllerServiceFactory|null $serviceFactory = null, Request|null $httpRequest = null, CsrfTokenService|null $csrfTokenService = null, MessageService|null $messageService = null, UserContextService|null $userContextService = null, PageOutputInterface|null $pageOutput = null, SessionInterface|null $session = null)

No description

Details

__construct(ConfigurationInterface $config, PDO $db, LoggerInterface $logger, ModuleRegistry $moduleRegistry, ControllerServiceFactory|null $serviceFactory = null, Request|null $httpRequest = null, CsrfTokenService|null $csrfTokenService = null, MessageService|null $messageService = null, UserContextService|null $userContextService = null, PageOutputInterface|null $pageOutput = null, SessionInterface|null $session = null)

No description

Parameters

ConfigurationInterface $config
PDO $db
LoggerInterface $logger
ModuleRegistry $moduleRegistry
ControllerServiceFactory|null $serviceFactory
Request|null $httpRequest
CsrfTokenService|null $csrfTokenService
MessageService|null $messageService
UserContextService|null $userContextService
PageOutputInterface|null $pageOutput
SessionInterface|null $session