AfterFileStorageTreeItemsPreparedEvent
New in version 14.0
This PSR-14 event was introduced to add visual cues and improved accessibility for editors working with file storage and folders.
The PSR-14 event
\TYPO3\
allows file storage tree items to be modified.
It is dispatched in the
\TYPO3\
class after the file storage tree items have been resolved and prepared. The event
provides the current PSR-7 request object and the file storage tree items.
Labels
Tree node labels can be defined to improve accessibility. Each node can have multiple labels, sorted by priority, with the highest priority label taking precedence. All the other labels will be added to the title attribute of the node.
A label can be assigned to a node in user TSconfig using a folder identifier path:
options.folderTree.label.1:/campaigns {
label = Main Storage
color = #ff8700
}
Status information
Status information can be added via the event to provide additional visual cues. Like labels, status information is sorted by priority, and only the highest priority status information is displayed. All status labels are added to the title attribute.
Example
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\AfterFileStorageTreeItemsPreparedEvent;
use TYPO3\CMS\Backend\Dto\Tree\Label\Label;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(
identifier: 'my-extension/backend/modify-file-storage-tree-items',
)]
final readonly class ModifyFileStorageTreeItems
{
public function __invoke(AfterFileStorageTreeItemsPreparedEvent $event): void
{
$items = $event->getItems();
foreach ($items as &$item) {
// Add special label for storage with uid 1
if ($item['resource']->getCombinedIdentifier() === '1:/campaigns/') {
$item['labels'][] = new Label(
label: 'A label',
color: '#abcdef',
priority: 10,
);
$item['statusInformation'][] = new StatusInformation(
label: 'An important information',
severity: ContextualFeedbackSeverity::INFO,
priority: 10,
icon: 'content-info',
);
}
}
$event->setItems($items);
}
}
API
- class AfterFileStorageTreeItemsPreparedEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Controller\ Event\ After File Storage Tree Items Prepared Event
Listeners to this event will be able to modify the prepared file storage tree items for the file / folder tree
Note
The folder identifier path used in TSconfig must not be URL-encoded.
For example, use
1:/ instead of
1%3A%2F.