Presentation

UI Components

Znovupoužitelné presentation blocks registrované přes service providers a dostupné přes ComponentRegistry.

What UI Components are for

ComponentRegistry is the shared registry for reusable UI/application components. Framework automatically registers breadcrumb, pagination and meta. Applications can register additional components through config and resolve them from the same registry.

How they are wired

ComponentServiceProvider delegates built-in wiring to BreadcrumbServiceProvider, PaginationServiceProvider and MetaServiceProvider, then builds ComponentRegistry with built-ins and app-defined components from config key components.

$this->registerBreadcrumb($container);
$this->registerPagination($container);
$this->registerMeta($container);
$this->registerRegistry($container);

Component registry contract

ComponentRegistry maps names to classes and resolves instances via DI. Built-ins expose explicit typed accessors (breadcrumb(), pagination(), meta()). Custom components are resolved via get(name, ExpectedClass::class). Unknown names and wrong expected type throw clear RuntimeException.

$components = $container->get(ComponentRegistry::class);

$breadcrumb = $components->breadcrumb();
$pagination = $components->pagination();
$meta = $components->meta();

Custom component registration

Register app components through top-level config key components. Existing demo app contains App\Component\NavigationComponent and resolves it through typed lookup.

// app/Config/App.php
use App\Component\NavigationComponent;

return [
    'components' => [
        'navigation' => NavigationComponent::class,
    ],
];

// usage
$components = $container->get(ComponentRegistry::class);
$navigation = $components->get('navigation', NavigationComponent::class);
$items = $navigation->items();

Validation and overrides

Config validation rules: components must be array, key must be non-empty string, value must be an existing class-string. Custom registration may intentionally override a default component name (for example pagination) when replacement is API-compatible.

Built-in component pages

System components are documented on dedicated subpages with API and examples: Breadcrumb, Pagination and Meta.

Template usage

Views get component shared from ViewServiceProvider. Built-ins can use typed accessors. Custom components do not use dynamic methods and do not use __call(); resolve them via get(name, ExpectedClass::class).

<?= $component->breadcrumb()->render($trail ?? null) ?>
<?= $component->pagination()->render($pagination ?? null) ?>
<?= $component->meta()->render($metaData) ?>