class AppManager (View source)

Builds the Twig environment with theme, translator and extensions, and renders templates for web controllers.

Properties

protected Environment $templateRenderer
protected ConfigurationInterface $configuration
protected StatsDisplayService|null $statsDisplayService

Methods

__construct(ConfigurationInterface $configuration, ModuleRegistry $registry, LoggerInterface $logger)

Initializes the template renderer and the optional statistics display service.

string
getThemeName()

Gets the theme name that templates are actually served from, which is 'default' when the configured theme directory does not exist.

string
getThemeBasePath()

Gets the theme base path matching the resolved theme, in the relative/URL form used for asset paths in templates.

void
addTwigExtension(ExtensionInterface $extension)

Registers an extension on the template renderer. Must be called before the first render of the request - Twig locks extensions afterwards.

void
addTwigGlobal(string $name, mixed $value)

Registers a global template variable. New names must be registered before the first render of the request; re-registering an existing name afterwards only updates its value.

void
render(string $template, array $params = [])

Renders a template with the given parameters.

string
getInterfaceLocale()

Gets the locale the translator was built with. Page chrome must use this (not re-resolve) so rendered strings and lang metadata agree.

array
getSupportedLocales()

Gets the enabled locales as resolved for this request.

string
displayStats()

Displays the application statistics.

Details

__construct(ConfigurationInterface $configuration, ModuleRegistry $registry, LoggerInterface $logger)

Initializes the template renderer and the optional statistics display service.

Parameters

ConfigurationInterface $configuration
ModuleRegistry $registry

The request's loaded registry; its enabled modules become template namespaces

LoggerInterface $logger

string getThemeName()

Gets the theme name that templates are actually served from, which is 'default' when the configured theme directory does not exist.

Return Value

string

The resolved theme name

string getThemeBasePath()

Gets the theme base path matching the resolved theme, in the relative/URL form used for asset paths in templates.

Return Value

string

The resolved theme base path

void addTwigExtension(ExtensionInterface $extension)

Registers an extension on the template renderer. Must be called before the first render of the request - Twig locks extensions afterwards.

Parameters

ExtensionInterface $extension

The Twig extension to register

Return Value

void

void addTwigGlobal(string $name, mixed $value)

Registers a global template variable. New names must be registered before the first render of the request; re-registering an existing name afterwards only updates its value.

Parameters

string $name

The variable name available to all templates

mixed $value

The value to expose

Return Value

void

void render(string $template, array $params = [])

Renders a template with the given parameters.

Parameters

string $template

The template file to render

array $params

The parameters to pass to the template

Return Value

void

string getInterfaceLocale()

Gets the locale the translator was built with. Page chrome must use this (not re-resolve) so rendered strings and lang metadata agree.

Return Value

string

The resolved interface locale

array getSupportedLocales()

Gets the enabled locales as resolved for this request.

Return Value

array

The enabled locales, trimmed

string displayStats()

Displays the application statistics.

Return Value

string

The statistics display