lynx-ripe/swix-em-config

Swix Event Manager configuration helper module. Allows to attach listeners and aggregates via application config

dev-master 2019-05-16 23:45 UTC

This package is auto-updated.

Last update: 2025-08-17 13:49:01 UTC


README

Zend Framework 2 module which provides possibility to attach event listeners and aggregates to SharedEventManager via configuration.

Installation

Add this line to your composer require key: "swix/swix-em-config": "dev-master" and update Composer. Then enable SwixEmConfig module in your application config.

Important note

Event listeners can be attached only after loading of all modules (ModuleEvent::EVENT_LOAD_MODULES_POST)

Example

In your application or module config:

<?php
use Zend\Mvc\MvcEvent;

return [
    'service_manager' =>  [
        'invokables' => [
            'SomeAggregate' => 'SomeNamespaces\SomeAggregate',
            'BootstrapListener' => 'SomeNamespaces\BootstrapListener'
        ]
    ],
    'event_manager' => [
        'listeners' => [
            // This listener will be retrived via ServiceManager
            ['event' => MvcEvent::EVENT_BOOTSTRAP, 'listener' => 'BootstrapListener']
            // This listener will be created directly if its class exists
            ['event' => 'some_event', 'listener' => SomeNamespaces\WithoutSM\BootstrapListener::class]
        ],
        'aggregates' => [
            ['aggregate' => 'SomeAggregate']
        ]
    ]
]