PHP code example of macs / rad-domain-event

1. Go to this page and download the library: Download macs/rad-domain-event library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

macs / rad-domain-event example snippets


public function registerBundles()
{
    $bundles = array(
        // bundles here ...
        new Knp\Rad\DomainEvent\Bundle\DomainEventBundle();
    );
}

use Knp\Rad\DomainEvent;

class MyEntity implements DomainEvent\Provider
{
    use DomainEvent\ProviderTrait;
}

use Knp\Rad\DomainEvent;

class MyEntity implements DomainEvent\Provider
{
    // ...
    public function myFunction($arg) {
        // your function behavior
        $this->raise('myEventName', ['anyKey' => $anyValue]);
    }
}

use Knp\Rad\DomainEvent\Event;

class MyListener
{
    public function onMyEventName(Event $event) {
        // your function behavior     
    }
}