Feature #48409

Introduce new Annotation "Slot" for wiring signal and slots

Added by Philipp Maier over 8 years ago. Updated over 8 years ago.

Could have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Has patch:


With this, the manual wiring in the Package.php could be left out so instead of doing this:

$dispatcher = $bootstrap->getSignalSlotDispatcher();
    'Some\Package\Controller\CommentController', 'commentCreated', //signal
    'Some\Package\Service\Notification', 'sendNewCommentNotification' // slot

one could easily add the Slot configuration to the respective function in the Class:

 * @Flow\Slot('Some\Package\Controller\CommentController', 'commentCreated')
 * @param Comment $comment
 * @return void
public function sendNewCommentNotification(Comment $comment) { ...

Future implementations could even allow Pointcut Expressions for e. g. Domain Events @Flow\Slot("class(Some\Package\Domain\Event\SomeEvent)")

Christian Müller however pointed out that this idea has been dropped in the past for a reason he couldn't remember.
So if anyone knows why this is a bad idea, let me know. If nothing speaks against implementing this: This is more of a "Flow-like" API imho.


Updated by Henrik Møller Rasmussen over 8 years ago

Just a small note regarding the domain event part. To have proper support for domain events, it needs to be ensured that the signal is only triggered after the database transaction is committed successful.

Fx. a signal that sends an OrderCompleted email should not be triggered if the transaction saving the order does not complete.


Updated by Philipp Maier over 8 years ago

Good point, which means that before sending out an Event a persistenceManager->persistAll should be called. Only works if the identity is generated early though, as there is no way to 'refresh' a loaded Entity yet.

Not related to the Annotation though, if I get this right. Might need to open a new issue concerning implementation of Domain Events.

Also available in: Atom PDF