t4web / event-subscriber
ZF2 Module. One place for manage application events
Installs: 7 087
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=5.5.0
- zendframework/zend-eventmanager: 3.2.*
- zendframework/zend-servicemanager: 3.3.*
Requires (Dev)
- phpunit/phpunit: ~4.5
- squizlabs/php_codesniffer: ^2.3
README
ZF2 Module. One place for manage application events.
Instalation
Add to your composer.json
:
"t4web/event-subscriber": "~1.0.0"
And to your config/application.config.php
:
'modules' => [ // ... 'T4web\EventSubscriber', // ... ],
Problem
As usual your event handlers everywhere, and you (or team member) don't know what will be executed
when you see this code $this->getEventManager()->trigger($event);
. You spend many time with
Crtl+F
in whole project.
Solution
It just recommendation (or team rule) - describe all your handlers in one place in your
module.config.php
:
'events' => [ 'Zend\Mvc\Application' => [ 'render' => [ SomeListenerOne::class, ], ], 'Users\User\Infrastructure\Repository' => [ 'create' => [ SomeListenerTwo::class, SomeListenerThree::class, ], ], 'Users\User\Infrastructure\Repository' => [ 'status:change' => [ CreateTimelineEntryListener::class, UserNotifyListener::class, ExpireUserTokensListener::class, AdminLogListener::class, ], ], // ... 'EventIdentifier' => [ 'EventName' => [ 'Callback1', // can be invokable class 'Callback2', // ... 'CallbackN', ], ], ],
T4web\EventSubscriber
- read this config and attach every handler in described event.