class AppManager (View source)

Class AppManager

Manages the application configuration, template rendering, and statistics display.

Properties

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

Methods

__construct(LoggerInterface|null $logger = null)

AppManager constructor.

static void
assertConfigurationUsable(ConfigurationManager $configuration)

Fails fast on broken configuration. Static and free of template setup so callers can check before, or without, building the Twig stack.

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(LoggerInterface|null $logger = null)

AppManager constructor.

Initializes the template renderer, configuration, and optional statistics display service.

Parameters

LoggerInterface|null $logger

static void assertConfigurationUsable(ConfigurationManager $configuration)

Fails fast on broken configuration. Static and free of template setup so callers can check before, or without, building the Twig stack.

Parameters

ConfigurationManager $configuration

Return Value

void

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