ComponentFactory
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
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
$iconFactory
protected
IconFactory
$iconFactory
Methods
__construct()
public
__construct(IconFactory $iconFactory) : mixed
Parameters
- $iconFactory : IconFactory
createBackButton()
Creates a standardized "back" navigation button.
public
createBackButton(string|UriInterface $returnUrl) : LinkButton
Parameters
- $returnUrl : string|UriInterface
Return values
LinkButtoncreateCloseButton()
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
LinkButtoncreateDropDownButton()
public
createDropDownButton() : DropDownButton
Return values
DropDownButtoncreateFullyRenderedButton()
public
createFullyRenderedButton() : FullyRenderedButton
Return values
FullyRenderedButtoncreateGenericButton()
public
createGenericButton() : GenericButton
Return values
GenericButtoncreateInputButton()
public
createInputButton() : InputButton
Return values
InputButtoncreateLinkButton()
public
createLinkButton() : LinkButton
Return values
LinkButtoncreateMenu()
public
createMenu() : Menu
Return values
MenucreateMenuItem()
public
createMenuItem() : MenuItem
Return values
MenuItemcreateReloadButton()
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
LinkButtoncreateSaveButton()
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
createShortcutButton()
public
createShortcutButton() : ShortcutButton
Return values
ShortcutButtoncreateSplitButton()
public
createSplitButton() : SplitButton
Return values
SplitButtoncreateViewButton()
public
createViewButton([array<string|int, mixed> $previewDataAttributes = [] ]) : LinkButton
Parameters
- $previewDataAttributes : array<string|int, mixed> = []
Return values
LinkButtongetLanguageService()
protected
getLanguageService() : LanguageService