PSR-14 Events
Table of Contents
The extension contains some PSR-14 events which make it possible to extend the extension with own functionality. You can for example adjust the status selection or react on status changes for implementing some kind of a workflow.
If you are new to PSR-14 events, please refer to the official TYPO3 documentation about PSR-14 events and Event Listeners.
PrepareStatusSelectionEvent
This event is dispatched before the status selection is rendered. You can use it to modify the available status options.
<?php
namespace MyVendor\MyExtension\EventListener;
use Xima\XimaTypo3ContentPlanner\Event\PrepareStatusSelectionEvent;
final class ModifyStatusSelectionListener
{
public function __invoke(PrepareStatusSelectionEvent $event): void
{
$table = $event->getTable();
$uid = $event->getUid();
$selectionEntries = $event->getSelectionEntriesToAdd();
// Remove a specific status from selection
unset($selectionEntries['3']);
$event->setSelectionEntriesToAdd($selectionEntries);
}
}
MyVendor\MyExtension\EventListener\ModifyStatusSelectionListener:
tags:
- name: event.listener
identifier: 'my-extension/modify-status-selection'
StatusChangeEvent
This event is dispatched after the status of a record has been changed. You can use it to trigger additional actions like notifications or workflow transitions.
Note that $newStatus may be null when a status is cleared from a record.
<?php
namespace MyVendor\MyExtension\EventListener;
use Xima\XimaTypo3ContentPlanner\Event\StatusChangeEvent;
final class StatusChangeListener
{
public function __invoke(StatusChangeEvent $event): void
{
$table = $event->getTable();
$uid = $event->getUid();
$newStatus = $event->getNewStatus();
$previousStatus = $event->getPreviousStatus();
// Example: Send notification when status changes to a specific status (uid 3)
if ($newStatus?->getUid() === 3) {
// Trigger notification logic
}
}
}
MyVendor\MyExtension\EventListener\StatusChangeListener:
tags:
- name: event.listener
identifier: 'my-extension/status-change'
CommentCreatedEvent
This event is dispatched after a new comment has been saved to the database. This includes both root comments and replies. Use it for notifications, activity logging, or integration with external systems.
The table property refers to the record being commented on (e.g. pages), not the comment table itself.
<?php
namespace MyVendor\MyExtension\EventListener;
use Xima\XimaTypo3ContentPlanner\Event\CommentCreatedEvent;
final class CommentNotificationListener
{
public function __invoke(CommentCreatedEvent $event): void
{
$table = $event->getTable(); // e.g. 'pages'
$recordUid = $event->getRecordUid(); // UID of the commented record
$commentUid = $event->getCommentUid(); // UID of the new comment
$authorUid = $event->getAuthorUid(); // UID of the backend user
// Example: Send Slack notification
}
}
MyVendor\MyExtension\EventListener\CommentNotificationListener:
tags:
- name: event.listener
identifier: 'my-extension/comment-notification'
CommentResolvedEvent
This event is dispatched when a comment is marked as resolved. It is not dispatched when a comment is reopened (unresolved).
<?php
namespace MyVendor\MyExtension\EventListener;
use Xima\XimaTypo3ContentPlanner\Event\CommentResolvedEvent;
final class CommentResolvedListener
{
public function __invoke(CommentResolvedEvent $event): void
{
$table = $event->getTable(); // e.g. 'pages'
$recordUid = $event->getRecordUid(); // UID of the commented record
$commentUid = $event->getCommentUid(); // UID of the resolved comment
$resolvedByUid = $event->getResolvedByUid(); // UID of the resolving user
// Example: Log resolution for audit trail
}
}
MyVendor\MyExtension\EventListener\CommentResolvedListener:
tags:
- name: event.listener
identifier: 'my-extension/comment-resolved'
See also
View the sources on GitHub: