APPNETOS is under active development This website and its documentation are being prepared for public launch. Content and features may change.
Select Theme
Loading

Ui

Manages UI framework versions, theme, HTML attributes and additional head assets. It provides global UI metadata consumed by rendering.

Purpose

Manages UI framework versions, theme, HTML attributes and additional head assets. It provides global UI metadata consumed by rendering.

UI integration

The UI controller manages HTML attributes, HTML classes, theme and additional head assets. Templates can consume these values through the rendering variable layer.

Public API Reference

Core\Ui

Class & Registry

Class: Core\Ui

Extends: Core\Ui\Base

use Core\Ui;
use Core\Registry;

$ui = Registry::get(Ui::class);
Method Description
public function getBootstrapVersion(): BootstrapVersion|null Get configured Bootstrap version Returning null disables both Bootstrap CSS and Bootstrap JavaScript.
public function getBootstrapIconsVersion(): BootstrapIconsVersion|null Get configured Bootstrap Icons version Returning null disables automatic Bootstrap Icons CSS registration.
public function getTheme(): string|null Get configured UI theme The theme is metadata only. No theme CSS is registered automatically.
public function setHtmlAttribute(string $name, string $value): static Set an attribute on the root HTML element Setting the class attribute replaces existing classes. Use addHtmlClass() to append classes.
public function getHtmlAttribute(string $name): string|null Get an attribute of the root HTML element
public function removeHtmlAttribute(string $name): static Remove an attribute from the root HTML element
public function addHtmlClass(string $classes): static Add one or more classes to the root HTML element without duplicates
public function getHtmlAttributes(): array Get all root HTML element attributes
public function addAsset(string $source, array $attributes = []): void Register an additional HTML head link asset The default attributes preload an image. Other asset types can supply their own rel, as and other link
public function getAssets(): array Get registered HTML head link assets
public function getAll(): array Get current UI configuration and additional head assets Designed for use by the Core Render Variables Container as the ui template variable.

Context implementations

APPNETOS provides application and administration implementations of this controller. Use the class mapped for the active runtime context; shared base classes describe common behavior, while concrete implementations may supply context-specific dependencies.

Bootstrap asset registration

getBootstrapVersion() and getBootstrapIconsVersion() are independent. A null result disables automatic registration. Bootstrap CSS and the JS bundle use priority -100; Bootstrap Icons CSS uses -90. Resource paths use the complete configured version; version-dependent Twig templates use compatible major/minor paths.

Root HTML attributes and language

getHtmlAttributes() combines explicitly configured attributes with automatically derived values. Core\Languages::getActive() provides the active language: de_de becomes lang="de-DE"; global produces no automatic language attribute. Explicit lang always takes precedence.

$ui = Registry::get(Ui::class);
$ui->addHtmlClass('dark-mode');
$ui->setHtmlAttribute('dir', 'ltr');
$ui->setHtmlAttribute('data-feature', 'enabled');

Theme metadata versus styling

A nonempty theme identifier produces data-appnetos-theme unless explicitly overridden. It does not load theme CSS or set data-bs-theme. Register theme CSS through Core\Css; set Bootstrap-specific attributes explicitly when needed. A server-side dark-mode HTML class is used for Swagger UI in appnetos-api-dev.

addAsset() adds link resources; by default it preloads an image. Empty sources are ignored and identical entries are deduplicated. Use Core\Css for stylesheets and Core\Js for scripts.

$ui->addAsset('/src/example/hero.webp');
$ui->addAsset('https://static.example.com', [
    'rel' => 'preconnect',
    'crossorigin' => 'anonymous',
]);

Base template output

The shared base template renders escaped dynamic HTML attributes and head link attributes without hardcoding Bootstrap-specific markup.


<html{% if ui.html_attributes is defined %}
    {% for name, value in ui.html_attributes %}
        {{ name|e('html_attr') }}="{{ value|e('html_attr') }}"
    {% endfor %}
{% endif %}>

Suggested head order: meta tags, title, favicon, UI head links, DebugBar head, CSS, JavaScript.

Next Steps

Previous

Rendering & UI

Explore Rendering & UI

Next

Render

Explore Render