antismok / domain-events-publisher-bundle
symfony bundle for domain event publisher
Installs: 9 257
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:bundle
Requires
This package is auto-updated.
Last update: 2024-09-29 05:08:36 UTC
README
symfony bundle for domain event publisher
Subscribe to domain event
some_domain_listener: class: Antismok\Identity\Application\UserCreatedHandler tags: - { name: domain.event_listener, event: Antismok\Identity\Domain\UserCreatedEvent, method: handle}
declare(strict_types=1); namespace Antismok\Identity\Application; use Antismok\Identity\Domain\UserCreatedEvent; class UserCreatedHandler { public function handle(UserCreatedEvent $event) { //.... } }
Call in model
<?php declare(strict_types=1); namespace Antismok\Identity\Domain\Model; use Antismok\DomainEventPublisher\DomainEventPublisher; use Antismok\Identity\Domain\UserCreatedEvent; class User { public function register(string $id, string $login): void { //..... DomainEventPublisher::getInstance() ->publish(new UserCreatedEvent($id, $login)) ; } }
You can use di service @domain_event_dispatcher or @Antismok\DomainEventPublisher\DomainEventPublisher