abacaphiliac / events-capable
Provides a config-based initializer that attaches listeners to implementations of \Zend\EventManager\EventsCapableInterface.
Installs: 13 104
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Requires
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.2
- phing/phing: ^2
- phpunit/phpunit: ^5|^4.8
- squizlabs/php_codesniffer: ^2.5
- zendframework/zend-validator: ^2
This package is auto-updated.
Last update: 2024-11-25 12:08:34 UTC
README
abacaphiliac/events-capable
Tired of writing backwards-compatible logic in all of your factory code to wire up listeners? Is your service implementation registered with Zend's service manager? Then this package might be right for you!
This package provides a config-based initializer that attaches listeners to implementations of
\Zend\EventManager\EventsCapableInterface
.
When the service concrete is instantiated by service manager, it will pass through the initializer provided by this
package. If your service is Events Capable, then the initializer will check the config for registered listeners
to attach to the service's event manager.
Installation
Install the latest version with
composer require abacaphiliac/events-capable
Basic Usage (Configuration)
- Update
service_manager
config.- Add initializer.
- Add listener.
- Update
abacaphiliac/events-capable
config:- Add
\Zend\EventManager\EventsCapableInterface
implementation. - Add
\Zend\EventManager\ListenerAggregateInterface
implementation.
- Add
Configuration Examples
Update service_manager config:
return [ 'service_manager' => [ 'factories' => [ \MyListener::class => \MyListenerFactory::class, ], 'initializers' => [ \abacaphiliac\EventsCapable\EventsCapableInitializer::class, ], ], ];
Update abacaphiliac/events-capable config:
return [ 'abacaphiliac/events-capable' => [ 'eventsCapable' => [ \MyEventsCapableService::class => [ \MyListener::class, ], ], ], ];
Contributing
composer install && vendor/bin/phing
This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.