Skip to content

ControllerInterface

What the framework asks of a controller: resolve and build the action and view for a dispatch, answer questions about what a module contains, and hold the response being assembled.

Narrower than Controller: startup(), shutdown(), reset() and initialize() drive the controller’s own lifecycle and belong to the context that owns it, not to the middleware and services that dispatch through it.

interface ControllerInterface

Implemented byController
Since3.2.0
SourceController/ControllerInterface.php
MethodDescription
actionExists(string $moduleName, string $actionName): boolWhether an action exists in a module.
createActionInstance(string $moduleName, string $actionName): ActionBuild (and initialize) an action instance for a module.
createViewInstance(string $moduleName, string $viewName): ViewBuild a view instance for a module.
getContext(): ContextThe context this controller belongs to.
getGlobalResponse(): WebResponseThe response being assembled for this request.
getOutputType(?string $name = null): OutputTypeA configured output type by name, or the default when $name is null.
getOutputTypeNames(): array<int, string>The names of every configured output type.
initializeModule(string $moduleName): mixedLoad a module’s autoload and configuration, once per process.
modelExists(string $moduleName, string $modelName): boolWhether a model exists in a module.
moduleExists(string $moduleName): boolWhether a module exists.
viewExists(string $moduleName, string $viewName): boolWhether a view exists in a module.

abstract public function actionExists(string $moduleName, string $actionName): bool

Whether an action exists in a module.

ParameterTypeDescription
$moduleNamestring
$actionNamestring

Returns bool

abstract public function createActionInstance(string $moduleName, string $actionName): Action

Build (and initialize) an action instance for a module.

ParameterTypeDescription
$moduleNamestring
$actionNamestring

Returns Action

abstract public function createViewInstance(string $moduleName, string $viewName): View

Build a view instance for a module.

ParameterTypeDescription
$moduleNamestring
$viewNamestring

Returns View

abstract public function getContext(): Context

The context this controller belongs to.

Returns Context

abstract public function getGlobalResponse(): WebResponse

The response being assembled for this request.

Returns WebResponse

abstract public function getOutputType(?string $name = null): OutputType

A configured output type by name, or the default when $name is null.

ParameterTypeDescription
$name?``string

Returns OutputType

abstract public function getOutputTypeNames(): array<int, string>

The names of every configured output type.

Returns array``<``int``, ``string``>

abstract public function initializeModule(string $moduleName): mixed

Load a module’s autoload and configuration, once per process.

ParameterTypeDescription
$moduleNamestring

Returns mixed

ThrowsWhen
DisabledModuleExceptionIf the module is disabled.

abstract public function modelExists(string $moduleName, string $modelName): bool

Whether a model exists in a module.

ParameterTypeDescription
$moduleNamestring
$modelNamestring

Returns bool

abstract public function moduleExists(string $moduleName): bool

Whether a module exists.

ParameterTypeDescription
$moduleNamestring

Returns bool

abstract public function viewExists(string $moduleName, string $viewName): bool

Whether a view exists in a module.

ParameterTypeDescription
$moduleNamestring
$viewNamestring

Returns bool