Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Domain Events Bundle Laravel Package

astina/domain-events-bundle

View on GitHub
Deep Wiki
Context7

Astina Domain Events Bundle

Configure services as Doctrine domain event listeners.

Note: this bundle is not production ready as it requires the master version of DoctrineBundle.

Installation

Step 1: Add to composer.json

"require":  {
    "astina/domain-events-bundle":"dev-master",
}

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Astina\Bundle\DomainEventsBundle\AstinaDomainEventsBundle(),
    );
}

##Usage

Create subscriber service:

class ProductSupplyWatcher
{
    public function preUpdate(ProductSupply $supply, PreUpdateEventArgs $event)
    {
        // do stuff
    }
}

Read more about the (optional) $event parameter in the Doctrine documentation about Entity Listeners.

<service id="product_supply_watcher" class="Astina\Bundle\SandboxBundle\Foo\ProductSupplyWatcher">
    <argument type="service" id="some_service" />
</service>

Configure domain event subscriber:

astina_domain_events:
    subscribers:
        product_supply_watcher: # this is the service id
            entity: Astina\Bundle\ShopBundle\Model\ProductSupply # entity class
            events: [ preUpdate ] # list of events to listen to

Note that the method name in the subscriber service corresponds with the event name.

Available events:

  • prePersist
  • postPersist
  • preUpdate
  • postUpdate
  • preRemove
  • postRemove
  • preFlush
  • postLoad

##Todo Add possibility to subscribe to changes on specific fields.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle