AfterPageTreeItemsPreparedEvent¶
New in version 12.0: This PSR-14 event replaces the following hooks:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Workspaces\Service\WorkspaceService']['hasPageRecordVersions']
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Workspaces\Service\WorkspaceService']['fetchPagesWithVersionsInTable']
The PSR-14 event
\TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent
allows prepared page tree items to be modified.
It is dispatched in the \TYPO3\CMS\Backend\Controller\Page\TreeController
class after the page tree items have been resolved and prepared. The event
provides the current PSR-7 request object as well as the page tree items. All
items contain the corresponding page record in the special _page
key.
Example¶
Registration of the event listener in the extension's Services.yaml
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Backend\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/backend/modify-page-tree-items'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent;
final class MyEventListener
{
public function __invoke(AfterPageTreeItemsPreparedEvent $event): void
{
$items = $event->getItems();
foreach ($items as $item) {
// Setting special item for page with id 123
if ($item['_page']['uid'] === 123) {
$item['icon'] = 'my-special-icon';
}
}
$event->setItems($items);
}
}
API¶
- class TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent¶
Listeners to this event will be able to modify the prepared page tree items for the page tree
- getRequest()¶
- Return type
Psr\Http\Message\ServerRequestInterface
- getItems()¶
- Return type
array
- setItems(array $items)¶
- Parameters
$items (
array
) -- the items