ComponentFactory

Read onlyYes

Factory for creating backend template components, e.g. buttons.

This ComponentFactory serves as the central location for all component creation in the backend, providing both pre-configured components for common patterns and basic component factory methods.

Currently focused on button creation, but designed to be extensible for other component types (menus, breadcrumbs, etc.) in the future.

This reduces boilerplate code and ensures consistent UX across the backend by providing standardized component configurations for recurring use cases.

Example - Creating a back button:

public function __construct(
    protected readonly ComponentFactory $componentFactory,
) }

public function myAction(): ResponseInterface
{
    $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();

    // Use pre-configured back button
    $backButton = $this->componentFactory->createBackButton($returnUrl);
    $buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
}
Attributes
#[Autoconfigure]
$public: true

Table of Contents

Properties

$iconFactory  : IconFactory

Methods

__construct()  : mixed
createBackButton()  : LinkButton
Creates a standardized "back" navigation button.
createCloseButton()  : LinkButton
Creates a standardized "close" button.
createDropDownButton()  : DropDownButton
createFullyRenderedButton()  : FullyRenderedButton
createGenericButton()  : GenericButton
createInputButton()  : InputButton
createLinkButton()  : LinkButton
createMenu()  : Menu
createMenuItem()  : MenuItem
createReloadButton()  : LinkButton
Creates a standardized "reload" button for reloading the current view.
createSaveButton()  : InputButton
Creates a standardized "save" button for forms.
createShortcutButton()  : ShortcutButton
createSplitButton()  : SplitButton
createViewButton()  : LinkButton
getLanguageService()  : LanguageService

Properties

Methods

createBackButton()

Creates a standardized "back" navigation button.

public createBackButton(string|UriInterface $returnUrl) : LinkButton
Parameters
$returnUrl : string|UriInterface
Return values
LinkButton

createCloseButton()

Creates a standardized "close" button.

public createCloseButton(string|UriInterface $closeUrl) : LinkButton

Similar to back button but uses "actions-close" icon and "Close" label. Typically used for closing detail views or modal-like overlays.

Parameters
$closeUrl : string|UriInterface
Return values
LinkButton

createReloadButton()

Creates a standardized "reload" button for reloading the current view.

public createReloadButton(string|UriInterface $requestUri) : LinkButton

Similar to back button but uses "actions-refresh" icon and without a displayed label.

Parameters
$requestUri : string|UriInterface
Return values
LinkButton

createSaveButton()

Creates a standardized "save" button for forms.

public createSaveButton([string $formName = '' ]) : InputButton

Returns an InputButton configured with:

  • "actions-document-save" icon
  • Translated "Save" label (shown as text)
  • name="_savedok" and value="1"
  • Associated with the specified form
Parameters
$formName : string = ''

The HTML form ID this button belongs to

Return values
InputButton

Fully configured save button

createViewButton()

public createViewButton([array<string|int, mixed> $previewDataAttributes = [] ]) : LinkButton
Parameters
$previewDataAttributes : array<string|int, mixed> = []
Return values
LinkButton

        
On this page

Search results