ShortcutButton implements ButtonInterface, PositionInterface

Renders a shortcut button in the DocHeader which automatically positions itself in the top right corner (BUTTON_POSITION_RIGHT, group 91).

This button implements PositionInterface, which means the position and group parameters passed to addButton() are ignored - the button always uses its own predefined position.

Example:

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

public function myAction(): ResponseInterface
{
    $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
    $pageId = (int)($request->getQueryParams()['id'] ?? 0);
    $myButton = $this->componentFactory->createShortcutButton()
          ->setRouteIdentifier('page_preview')
          ->setDisplayName('View page ' . $pageId)
          ->setArguments([
             'id' => $pageId
          ]);
    $buttonBar->addButton($myButton);
}

Table of Contents

Interfaces

ButtonInterface
Interface for buttons in the document header.
PositionInterface
Interface for buttons that define their own fixed position and group.

Properties

$arguments  : array<string|int, mixed>
$copyUrlToClipboard  : bool
$disabled  : bool
$displayName  : string
$routeIdentifier  : string

Methods

__toString()  : string
getDisplayName()  : string
getGroup()  : int
Returns the group number for this button.
getPosition()  : string
Returns the position where this button should be rendered.
getRouteIdentifier()  : string
getType()  : string
Returns the fully qualified class name as the component type identifier.
isDisabled()  : bool
isValid()  : bool
Validates whether the component is properly configured and can be rendered.
render()  : string
Renders the component as an HTML string.
setArguments()  : static
setCopyUrlToClipboard()  : static
Defines whether the shortcut button should be extended to also allow copying the current URL to the operating systems' clipboard.
setDisabled()  : static
setDisplayName()  : static
setRouteIdentifier()  : static
getBackendUser()  : BackendUserAuthentication
getDispatchActionAttrs()  : array<string|int, mixed>
Returns HTML attributes for client-side `ActionDispatcher` of the "add shortcut" button.
getLanguageService()  : LanguageService
routeExists()  : bool

Properties

$arguments

protected array<string|int, mixed> $arguments = []

List of parameter/value pairs relevant for this shortcut

$copyUrlToClipboard

protected bool $copyUrlToClipboard = true

$displayName

protected string $displayName = ''

$routeIdentifier

protected string $routeIdentifier = ''

Methods

__toString()

public __toString() : string
Return values
string

getDisplayName()

public getDisplayName() : string
Return values
string

getGroup()

Returns the group number for this button.

public getGroup() : int

Groups determine the visual grouping and order of buttons within a position. Lower numbers appear first.

Return values
int

The group number (e.g., 1, 10, 90, 91)

getPosition()

Returns the position where this button should be rendered.

public getPosition() : string
Return values
string

Either ButtonBar::BUTTON_POSITION_LEFT or ButtonBar::BUTTON_POSITION_RIGHT

getRouteIdentifier()

public getRouteIdentifier() : string
Return values
string

getType()

Returns the fully qualified class name as the component type identifier.

public getType() : string

This is used to identify the specific component type in validation and rendering.

Return values
string

The fully qualified class name (e.g., 'TYPO3\CMS\Backend\Template\Components\Buttons\LinkButton')

isDisabled()

public isDisabled() : bool
Return values
bool

isValid()

Validates whether the component is properly configured and can be rendered.

public isValid() : bool

Each implementing class defines its own validation rules (e.g., required fields).

Return values
bool

True if the component is valid and can be rendered, false otherwise

render()

Renders the component as an HTML string.

public render() : string

This method should only be called after validating the component with isValid(). The returned HTML is ready to be output to the browser.

Return values
string

The rendered HTML markup

setArguments()

public setArguments(array<string|int, mixed> $arguments) : static
Parameters
$arguments : array<string|int, mixed>
Return values
static

setCopyUrlToClipboard()

Defines whether the shortcut button should be extended to also allow copying the current URL to the operating systems' clipboard.

public setCopyUrlToClipboard(bool $copyUrlToClipboard) : static
Parameters
$copyUrlToClipboard : bool
Return values
static

setDisabled()

public setDisabled(bool $disabled) : static
Parameters
$disabled : bool
Return values
static

setDisplayName()

public setDisplayName(string $displayName) : static
Parameters
$displayName : string
Return values
static

setRouteIdentifier()

public setRouteIdentifier(string $routeIdentifier) : static
Parameters
$routeIdentifier : string
Return values
static

getDispatchActionAttrs()

Returns HTML attributes for client-side `ActionDispatcher` of the "add shortcut" button.

protected getDispatchActionAttrs(string $routeIdentifier, string $encodedArguments, string $confirmationText) : array<string|int, mixed>
Parameters
$routeIdentifier : string
$encodedArguments : string
$confirmationText : string
Return values
array<string|int, mixed>

routeExists()

protected routeExists(string $routeIdentifier) : bool
Parameters
$routeIdentifier : string
Return values
bool

        
On this page

Search results