Documentation

No matching pages.

API

Config

Facade

Lifecycle

Class: Controller

Full name: Azera\Core\Controller

Base class for controllers in Azera.

Public methods

getMiddlewares() ·

public function getMiddlewares(): array

Get the middleware for the controller. Usually used by the Dispatcher to build the middleware pipeline for the current request.

Return value

  • Type: array

getActionMiddlewares() ·

public function getActionMiddlewares(string $action): array

Get the middleware for a specific action. Usually used by the Dispatcher to build the middleware pipeline for the current request.

Parameters

Name Type Default Description
$action string - The name of the action (e.g. "editAction")

Return value

  • Type: array

context() ·

public function context(): Azera\AppContext

Get the current AppContext instance. Useful for accessing services or route info from the controller.

Return value


request() ·

public function request(): Azera\Http\Request

Get the current Request object from the context.

Return value


view() ·

public function view(): Azera\Core\ViewEngine

Get the ViewEngine from the context for rendering views.

Return value


session() ·

public function session(): Azera\Http\Session|null

Get the Session from the context. May return null if no session is available.

Return value


flash() ·

public function flash(): Azera\Http\Flash

Get the one-request message bag.

Sugar over AppContext::flash():

// POST /account — queue for the page after the redirect
$this->flash()->success('Account settings updated.');
return Response::redirect('/account');

// GET /account — show once
$messages = $this->flash()->consume();

Return value


translator() ·

public function translator(): Azera\Localization\Translator

Get the application-wide translation service.

Return value


t() ·

public function t(string $key, array $vars = [], string|null $domain = null, string|null $locale = null): string

Translate a key for this controller's output.

Sugar over translator(); templates bound through $ctx->translator()->bind($ctx->view()) resolve the same catalogue.

Parameters

Name Type Default Description
$key string - Message key (e.g. "nav.home").
$vars array [] Placeholder values for {name} substitution.
$domain string|null null Domain override for this call.
$locale string|null null Locale override for this call.

Return value

  • Type: string

intl() ·

public function intl(): Azera\Localization\Intl

Get the application-wide locale-aware formatting service.

Return value


cookies() ·

public function cookies(): Azera\Http\Cookies

Get the Cookies service from the context for managing cookies.

Return value


resolve() ·

public function resolve(string $id): object

Get a service from the context by class name.

Parameters

Name Type Default Description
$id string -

Return value

  • Type: object

db() ·

public function db(): Azera\Db\DatabaseManager

Get the database manager for persistence access.

Return value


cache() ·

public function cache(): Psr\SimpleCache\CacheInterface

Get the cache service.

Return value

  • Type: Psr\SimpleCache\CacheInterface

logger() ·

public function logger(): Psr\Log\LoggerInterface

Get the logger.

Return value

  • Type: Psr\Log\LoggerInterface

events() ·

public function events(): Psr\EventDispatcher\EventDispatcherInterface

Get the event dispatcher.

Return value

  • Type: Psr\EventDispatcher\EventDispatcherInterface

Back to the Index