ProcessFileListActionsEvent
The PSR-14 event
\TYPO3\
is fired after actions are generated for the
Media module files and folders listing.
This event can be used to manipulate icons/actions that are in the edit control section of the Media module files and folders listing.
Changed in version 14.0 Breaking: #107884 - Rework actions to use Buttons API with Components
Actions are button components instead of HTML strings, and primary and
secondary actions are set by the
Action enum.
Example: Add a button to the actions of a file
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\FileList\EventListener;
use TYPO3\CMS\Backend\Template\Components\ActionGroup;
use TYPO3\CMS\Backend\Template\Components\ComponentFactory;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent;
#[AsEventListener(
identifier: 'my-extension/process-file-list',
)]
final readonly class MyEventListener
{
public function __construct(
private ComponentFactory $componentFactory,
private IconFactory $iconFactory,
) {}
public function __invoke(ProcessFileListActionsEvent $event): void
{
if (!$event->isFile()) {
return;
}
// Add a button for files to the secondary actions
$button = $this->componentFactory->createGenericButton()
->setIcon($this->iconFactory->getIcon('actions-heart'))
->setTitle('Add to favorites');
$event->setAction($button, 'myFavorite', ActionGroup::secondary);
}
}
API
-
final class
ProcessFileListActionsEvent -
- Fully qualified name
-
\TYPO3\CMS\ Filelist\ Event\ Process File List Actions Event
Event fired to modify icons rendered for the file listings
setAction(?\TYPO3\CMS\Backend\Template\Components\ComponentInterface $action, string $actionName, \TYPO3\CMS\Backend\Template\Components\ActionGroup $group = \TYPO3\CMS\Backend\Template\Components\ActionGroup::secondary, string $before = '', string $after = '')-
Add a new action or override an existing one. Latter is only possible, in case $columnName is given. Otherwise, the column will be added with a numeric index, which is generally not recommended. It's also possible to define the position of an action with either the "before" or "after" argument, while their value must be an existing action.
Note: In case none or an invalid $group is provided, the new action will be added to the secondary group.
- param $action
-
the action
- param $actionName
-
the actionName
- param $group
-
the group, default: TYPO3CMSBackendTemplateComponentsActionGroup::secondary
- param $before
-
the before, default: ''
- param $after
-
the after, default: ''
hasAction(string $actionName, ?\TYPO3\CMS\Backend\Template\Components\ActionGroup $group = null)-
Whether the action exists in the given group. In case none or an invalid $group is provided, both groups will be checked.
- param $actionName
-
the actionName
- param $group
-
the group, default: null
- Returns
-
bool
getAction(string $actionName, ?\TYPO3\CMS\Backend\Template\Components\ActionGroup $group = null)-
Get action by its name. In case the action exists in both groups and none or an invalid $group is provided, the action from the "primary" group will be returned.
- param $actionName
-
the actionName
- param $group
-
the group, default: null
- Returns
-
?\TYPO3\ CMS\ Backend\ Template\ Components\ Component Interface
removeAction(string $actionName, ?\TYPO3\CMS\Backend\Template\Components\ActionGroup $group = null)-
Remove action by its name. In case the action exists in both groups and none or an invalid $group is provided, the action will be removed from both groups.
- param $actionName
-
the actionName
- param $group
-
the group, default: null
moveActionTo(string $actionName, \TYPO3\CMS\Backend\Template\Components\ActionGroup $group, string $before = '', string $after = '')- param $actionName
-
the actionName
- param $group
-
the group
- param $before
-
the before, default: ''
- param $after
-
the after, default: ''