Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (39 sloc) 1.46 KB

Define events with subscriber

You can now expose/define your loggable events from your bundle using event subscriber instead of defining in configuration file. What you need to do, define a easy_audit.event_subscriber service implementing Xiidea\EasyAuditBundle\Subscriber\EasyAuditEventSubscriberInterface

1. Write Your AuditLogEventSubscriber class

<?php
//src/App/Subscriber/MyAuditLogEventSubscriber.php

namespace App\Subscriber;

use Xiidea\EasyAuditBundle\Subscriber\EasyAuditEventSubscriberInterface

class MyAuditLogEventSubscriber implements EasyAuditEventSubscriberInterface
{
   public function getSubscribedEvents()
       {
           return array(
               "some_resolver" => "some_event",
               "some_other_resolver" => array(
                   "event_for_other_resolver_1",
                   "event_for_other_resolver_2"
               ),
               "event_for_default_resolver_1",
               "event_for_default_resolver_2",
               "event_for_default_resolver_3"
           );
       }

}

2. Define Subscriber as service

services:
     class: App\Subscriber\MyAuditLogEventSubscriber
     tags:
         - { name: easy_audit.event_subscriber }

If you want you can optionally define the resolver for the subscribed events like:

services:
     class: App\Subscriber\MyAuditLogEventSubscriber
     tags:
         - { name: easy_audit.event_subscriber, resolver : your_resolver_service_id }
You can’t perform that action at this time.