Events
Every action in t3oodle controllers dispatches a PSR-14 event you can listen to, to modify or extend the extension behaviour.
Note
Up to t3oodle 0.x the extension used Extbase signals and slots. They have been replaced by PSR-14 events. Signals and slots are not supported anymore.
Controller events
All events are located in the namespace \FGTCLB\. The controller events are dispatched by
\FGTCLB\.
| Event | Dispatched |
|---|---|
List | List action |
Show | Show action |
Show | Finish form is displayed |
Vote | A vote is stored |
Delete | A participant deletes the own vote |
Reset | All votes of a poll are reset |
New | New action (form to create a poll) |
Create | Before a new poll is persisted |
Create | After a new poll has been persisted |
Edit | Edit action (form to update a poll) |
Update | Before a poll is updated |
Update | After a poll has been updated |
Publish | A poll gets published |
Finish | A poll gets finished |
Delete | A poll gets deleted |
Finish | The suggestion mode of a poll gets finished |
New | Form to suggest a new option |
Create | Before a suggestion is persisted |
Create | After a suggestion has been persisted |
Edit | Form to edit a suggestion |
Update | Before a suggestion is updated |
Update | After a suggestion has been updated |
Delete | A suggestion gets deleted |
Most events provide the affected object (e.g. get, get), the TypoScript get and the
calling controller (get). Events for actions which render a template also provide the view
(get), so you can assign own variables to it.
Continue argument
Several events provide a set method (for example Vote, Create,
Update or Delete). By default, it is true.
When you set it to false in your listener, the original code following in the controller, is not executed anymore.
You can use this to prevent flash messages and redirects. Check the event class for the available methods.
Permission events
The permission events are located in \FGTCLB\. They allow you to overrule the
decision about a permission, see PollPermission. Every permission event provides is and
set.
CreatePoll Allowed Event DeletePoll Allowed Event DeleteSuggestion Allowed Event EditPoll Allowed Event EditSuggest Allowed Event FinishPoll Allowed Event FinishSuggestion Mode Allowed Event NewOptions Allowed Event NewPoll Allowed Event PublishPoll Allowed Event ShowPoll Allowed Event SuggestNew Options Allowed Event UpdateSuggestion Allowed Event VoteAllowed Event VoteDelete Allowed Event VoteReset Allowed Event
Repository event
\FGTCLB\ is dispatched by Poll and allows you
to modify the query constraints:
get/Constraints () setConstraints (array $constraints) getto build own constraintsQuery ()
Register a listener
Create a listener class in your extension and register it with the As attribute:
<?php
declare(strict_types=1);
namespace Vendor\MyExt\EventListener;
use FGTCLB\T3oodle\Event\VotePollEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
final class VoteListener
{
#[AsEventListener(identifier: 'my-ext/t3oodle-vote')]
public function __invoke(VotePollEvent $event): void
{
$vote = $event->getVote();
$isNew = $event->getIsNew();
// TODO: implement me
// Prevent the code following in controller, e.g. flash messages and redirect
// $event->setContinue(false);
}
}
Alternatively, you can register listeners with the event. tag in Configuration/Services.yaml.
t3oodle itself ships a listener, which you can use as reference: \FGTCLB\.