[FEATURE] Introduce PSR-14-based EventDispatcher as alternative for hooks 03/61303/16
authorBenni Mack <benni@typo3.org>
Mon, 15 Jul 2019 18:31:38 +0000 (20:31 +0200)
committerBenjamin Franzke <bfr@qbus.de>
Tue, 16 Jul 2019 13:48:32 +0000 (15:48 +0200)
commit0b0f5f1ed0b377ce14f2f5b556c4ba6b9f525397
tree1a728d4a5f411892de17d99b9b313009d15f8931
parent57b051d0cc33e9f9b9855c30badbfe1de0f0cf8d
[FEATURE] Introduce PSR-14-based EventDispatcher as alternative for hooks

The new PSR-14 standard for dispatching Events (that is: to extend
a Framework without having to modify a frameworks' code) adds
a EventDispatcher object that can dispatch Event objects to
EventListeners.

In PSR-14 every dispatched event is an object. It uses PHP class names as
identifiers for events. Class hierarchies may be used to group events.

A ListenerProvider object collects available listeners from an extension
and allows to listen and/or modify data provided by the Event object.

The current implementation relies on a custom TYPO3-specific
ListenerProvider that is configured using Symfony's Dependency Injection
tags.

As an example the Mailer-postProcInitialization signal/slot is
replaced by an Event.

This first patch introduces the feature, and does not deprecate
anything yet. The most important part is that new Events
can use this API instead of Hooks in TYPO3 v10.

Short-Term goal is to deprecate SignalSlot dispatcher in TYPO3 v10,
and migrate all signals to the EventDispatcher.

Resolves: #88770
Releases: master
Change-Id: I3649ddb9b9340640199279e6af3c040bffc397fe
Signed-off-by: Benni Mack <benni@typo3.org>
Signed-off-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61303
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
22 files changed:
composer.json
composer.lock
typo3/sysext/core/Classes/Compatibility/Slot/PostInitializeMailer.php [new file with mode: 0644]
typo3/sysext/core/Classes/DependencyInjection/ListenerProviderPass.php [new file with mode: 0644]
typo3/sysext/core/Classes/EventDispatcher/EventDispatcher.php [new file with mode: 0644]
typo3/sysext/core/Classes/EventDispatcher/ListenerProvider.php [new file with mode: 0644]
typo3/sysext/core/Classes/Mail/Event/AfterMailerInitializationEvent.php [new file with mode: 0644]
typo3/sysext/core/Classes/Mail/Mailer.php
typo3/sysext/core/Configuration/Services.php
typo3/sysext/core/Configuration/Services.yaml
typo3/sysext/core/Documentation/Changelog/master/Feature-88770-PSR-14BasedEventDispatcher.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/DependencyInjection/Fixtures/Package1/Configuration/Services.yaml [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/DependencyInjection/Fixtures/Package2/Configuration/Services.yaml [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/DependencyInjection/Fixtures/Package3/Configuration/Services.yaml [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/DependencyInjection/Fixtures/Package4Cycle/Configuration/Services.yaml [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/DependencyInjection/ListenerProviderPassTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/EventDispatcher/EventDispatcherTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/EventDispatcher/ListenerProviderTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Mail/MailerTest.php
typo3/sysext/core/composer.json
typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php
typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf