title: CakePHP 3 events
body: <p>I want to create an entry in my Notifications table if a particular find method has return value on my Contacts table.</p>
  
  <p>So in ContactsTable I create an event.</p>
  
  <pre><code>use Cake\Event\Event;
  
  public function checkDuplicates()
  {
      //... some code here
      $event = new Event('Model.Contacts.afterDuplicatesCheck', $this, [
              'duplicates' =&gt; $duplicates
          ]);
      $this-&gt;eventManager()-&gt;dispatch($event);
  }
  </code></pre>
  
  <p>I have created ContactsListener.php at /src/Event</p>
  
  <pre><code>namespace App\Event;
  
  use Cake\Event\Event;
  use Cake\Event\EventListenerInterface;
  use Cake\Log\Log;
  
  class ContactsListener implements EventListenerInterface
  {
  
      public function implementedEvents()
      {
          return [
              'Model.Contacts.afterDuplicatesCheck' =&gt; 'createNotificationAfterCheckDuplicates',
          ];
      }
  
      public function createNotificationAfterCheckDuplicates(Event $event, array $duplicates)
      {
          Log::debug('Here I am');
      }
  }
  </code></pre>
  
  <p>In my NotificationsTable.php I have the following code.</p>
  
  <pre><code>public function initialize(array $config)
  {
      $this-&gt;table('notifications');
      $this-&gt;displayField('id');
      $this-&gt;primaryKey('id');
  
      $listener = new ContactsListener();
      $this-&gt;eventManager()-&gt;on($listener);
  }
  </code></pre>
  
  <p>I guess this part is the problem, as I never get the log entries. The cookbook is not enough clear about this and all code what I found was not the same what the cookbook describes, even for cake 3.</p>
  
  <p>How and where should I attach the listener?</p>