antismok / domain-events-publisher-bundle
symfony bundle for domain event publisher
Package info
github.com/antismok/domain-events-publisher-bundle
Type:bundle
pkg:composer/antismok/domain-events-publisher-bundle
v1.1
2018-10-29 01:19 UTC
Requires
This package is auto-updated.
Last update: 2026-03-29 00:46:35 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