From 849328b91b731da9d926347f46832d2f45699f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20M=C3=BCller?= <typo3@krue.ml> Date: Mon, 4 Mar 2024 20:36:59 +0100 Subject: [PATCH] [DOCS] Adjust example in changelog for tree node status information The example has been adjusted to give an example how this feature can use for setting the new status information: with a PSR-14 event listener. Additionally, use named arguments in the example for tree node labels for instantiating the DTO. Resolves: #103276 Related: #103186 Releases: main Change-Id: I4441f58041ef6cfe0571e591e97b8d8374b39d4b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83205 Reviewed-by: Garvin Hicking <gh@faktor-e.de> Tested-by: Benjamin Franzke <ben@bnf.dev> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Benjamin Franzke <ben@bnf.dev> Tested-by: Garvin Hicking <gh@faktor-e.de> --- ...186-IntroduceTreeNodeStatusInformation.rst | 53 ++++++++++++++----- ...Feature-103211-IntroduceTreeNodeLabels.rst | 6 +-- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103186-IntroduceTreeNodeStatusInformation.rst b/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103186-IntroduceTreeNodeStatusInformation.rst index 328aed3d27de..e659330d2351 100644 --- a/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103186-IntroduceTreeNodeStatusInformation.rst +++ b/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103186-IntroduceTreeNodeStatusInformation.rst @@ -24,20 +24,45 @@ Each node can accommodate multiple status information, prioritized by severity and urgency. Critical messages take precedence over other status notifications. -.. code-block:: php - - new TreeItem( - ... - statusInformation: [ - new StatusInformation( - label: 'A warning message', - severity: ContextualFeedbackSeverity::WARNING, - priority: 0, - icon: 'actions-dot', - overlayIcon: '' - ) - ] - ), +For example, status information can be added by using the event +:php:`\TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent`: + +.. code-block:: php + :caption: EXT:my_extension/Classes/Backend/EventListener/ModifyPageTreeItems.php + :emphasize-lines: 21-27 + + <?php + + declare(strict_types=1); + + namespace MyVendor\MyExtension\Backend\EventListener; + + use TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent; + use TYPO3\CMS\Backend\Dto\Tree\Label\Label; + use TYPO3\CMS\Core\Attribute\AsEventListener; + + #[AsEventListener( + identifier: 'my-extension/backend/modify-page-tree-items', + )] + final readonly class ModifyPageTreeItems + { + public function __invoke(AfterPageTreeItemsPreparedEvent $event): void + { + $items = $event->getItems(); + foreach ($items as &$item) { + if ($item['_page']['uid'] === 123) { + $item['statusInformation'][] = new StatusInformation( + label: 'A warning message', + severity: ContextualFeedbackSeverity::WARNING, + priority: 0, + icon: 'actions-dot', + overlayIcon: '', + ); + } + } + $event->setItems($items); + } + } Impact ====== diff --git a/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103211-IntroduceTreeNodeLabels.rst b/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103211-IntroduceTreeNodeLabels.rst index 1ef9e75f2487..792a96a6e70a 100644 --- a/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103211-IntroduceTreeNodeLabels.rst +++ b/typo3/sysext/core/Documentation/Changelog/13.1/Feature-103211-IntroduceTreeNodeLabels.rst @@ -67,9 +67,9 @@ The labels can also be added by using the event // Add special label for all pages with parent page ID 123 if ($item['_page']['pid'] === 123) { $item['labels'][] = new Label( - 'Campaign B', // Label - '#00658f', // Color as RGB value - 1, // Priority + label: 'Campaign B', + color: '#00658f', + priority: 1, ); } } -- GitLab