Skip to content

Releases: gpslab/domain-event-bundle

Release 2.3.1

24 May 12:38
e02fad1
Compare
Choose a tag to compare

Changelog (since 2.3.0...2.3.1)

Release 2.3.0

25 Mar 16:56
0342c65
Compare
Choose a tag to compare

Changelog (since 2.2.0...2.3.0)

Release 2.2.0

15 Aug 14:56
2478554
Compare
Choose a tag to compare

Changelog (since 2.1.4...2.2.0)

Release 2.1.4

15 Aug 12:26
6f22238
Compare
Choose a tag to compare

Changelog (since 2.1.3...2.1.4)

Release 2.1.3

23 Oct 09:58
Compare
Choose a tag to compare

Changelog (since 2.1.2...2.1.3)

  • Restore tests
  • Change build icons

Release 2.1.2

19 Oct 12:32
Compare
Choose a tag to compare

Changelog (since 2.1.1...2.1.2)

  • Pull events from initialized Doctrine proxy classes [Bugfix]
  • Test on PHP 7.2
  • Test with Symfony 3.4, 4.1 and Doctrine 2.6
  • Create service aliases for EventBus and EventQueue
  • Subscribers tagged automatically

Release 2.1.1

03 Oct 09:21
Compare
Choose a tag to compare

Changelog (since 2.1.0...2.1.1)

  • Added ability to subscribe to events.

    use GpsLab\Domain\Event\Event;
    use GpsLab\Domain\Event\Listener\Subscriber;
    
    class SendEmailOnPurchaseOrderCreated implements Subscriber
    {
        private $mailer;
    
        public function __construct(\Swift_Mailer $mailer)
        {
            $this->mailer = $mailer;
        }
    
        public static function subscribedEvents()
        {
            return [
                PurchaseOrderCreatedEvent::class => ['onPurchaseOrderCreated'],
            ];
        }
    
        public function onPurchaseOrderCreated(PurchaseOrderCreatedEvent $event)
        {
            $message = $this->mailer
                ->createMessage()
                ->setTo('recipient@example.com')
                ->setBody(sprintf(
                    'Purchase order created at %s for customer #%s',
                    $event->getCreateAt()->format('Y-m-d'),
                    $event->getCustomer()->getId()
                ));
    
            $this->mailer->send($message);
        }
    }

    Register event subscriber

    services:
        acme.domain.purchase_order.event.created.send_email_subscriber:
            class: SendEmailOnPurchaseOrderCreated
            arguments: [ '@mailer' ]
            tags:
                - { name: domain_event.subscriber }

Release 2.1.0

17 Aug 15:20
Compare
Choose a tag to compare

Changelog (since 2.0.1...2.1.0)

  • Publish domain events on Doctrine events PreRemove/PostRemove [Bugfix]

    Befire:
    PreRemove and PostRemove events is ignored.

    After:
    If you need do somthing after entity is removed you can use PreRemove/PostRemove Lifecycle Events.

    /**
     * @ORM\Table(name="article")
     * @ORM\Entity()
     * @ORM\HasLifecycleCallbacks()
     */
    class Article
    {
        /**
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="IDENTITY")
         * @ORM\Column(name="id", type="ArticleId", nullable=false)
         */
        private $id;
    
        /**
         * @ORM\Column(name="cover", type="string", length=255, nullable=true)
         */
        private $cover;
    
        // ...
    
        /**
         * @ORM\PreRemove()
         */
        public function preRemove()
        {
            // remove cover after remove article 
            $this->raise(new ArticleRemoved($this->id, $this->cover));
        }
    
        /**
         * @ORM\PostRemove()
         */
        public function postRemove()
        {
            // $this->id is null
        }
    }

Release 2.0.1

20 Jul 09:25
Compare
Choose a tag to compare

Changelog (since 2.0.0...2.0.1)

  • Correct domain_event.bus.listener_located service name.

Release 2.0.0

17 Jul 11:16
Compare
Choose a tag to compare

Changelog (since 1.1.0...2.0.0)

Configuration

Before:

gpslab_domain_event:
    # Event bus service
    # Support 'listener_locator', 'queue' or a custom service
    # As a default used 'listener_locator'
    bus: 'listener_locator'

    # Event queue service
    # Support 'memory', 'memory_unique' or a custom service
    # As a default used 'memory_unique'
    queue: 'memory_unique'

    # Event listener locator
    # Support 'voter', 'named_event' or custom service
    # As a default used 'named_event'
    locator: 'named_event'

    # Evant name resolver used in 'named_event' event listener locator
    # Support 'event_class', 'event_class_last_part', 'named_event' or a custom service
    # As a default used 'event_class'
    name_resolver: 'event_class'

After:

gpslab_domain_event:
    # Event bus service
    # Support 'listener_located', 'queue' or a custom service
    # As a default used 'listener_located'
    bus: 'listener_located'

    # Event queue service
    # Support 'pull_memory', 'subscribe_executing' or a custom service
    # As a default used 'pull_memory'
    queue: 'pull_memory'

    # Event listener locator
    # Support 'symfony', 'container', 'direct_binding' or custom service
    # As a default used 'symfony'
    locator: 'symfony'

    # Publish domain events post a Doctrine flush event
    # As a default used 'false'
    publish_on_flush: true

Publish domain events

  • Publish domain events post a Doctrine flush event.

Removed locators

  • Removed domain_event.locator.voter service.
  • Removed domain_event.locator.named_event service.
  • Ignore tag domain_event.locator.voter for VoterLocator.
  • Ignore tag domain_event.locator.named_event for NamedEventLocator.

Created locators

  • Created domain_event.locator.symfony service of
    GpsLab\Domain\Event\Listener\Locator\SymfonyContainerEventListenerLocator locator.
  • Created domain_event.locator.container service of
    GpsLab\Domain\Event\Listener\Locator\ContainerEventListenerLocator locator.
  • Created domain_event.locator.direct_binding service of
    GpsLab\Domain\Event\Listener\Locator\DirectBindingEventListenerLocator locator.

Removed name resolvers

  • Removed domain_event.name_resolver.event_class_last_part name resolver service.
  • Removed domain_event.name_resolver.event_class name resolver service.
  • Removed domain_event.name_resolver.named_event name resolver service.

Removed queue

  • Removed domain_event.queue.memory queue service.
  • Removed domain_event.queue.memory_unique queue service.

Created queue

  • Created domain_event.queue.pull_memory service of GpsLab\Domain\Event\Queue\Pull\MemoryPullEventQueue queue.
  • Created domain_event.queue.subscribe_executing service of
    GpsLab\Domain\Event\Queue\Subscribe\ExecutingSubscribeEventQueue queue.

Changed event bus

  • Changed class for domain_event.bus.listener_locator.

    Before used GpsLab\Domain\Event\Bus\Bus class.

    After used GpsLab\Domain\Event\Bus\ListenerLocatedEventBus class.

  • Service domain_event.bus.queue not use a domain_event.bus.listener_locator service.