Skip to content

Instantly share code, notes, and snippets.

@harikt
Last active January 13, 2016 17:20
Show Gist options
  • Save harikt/110dbf61cf089d3585f5 to your computer and use it in GitHub Desktop.
Save harikt/110dbf61cf089d3585f5 to your computer and use it in GitHub Desktop.
<?php
use Cake\Event\EventManager;
$listener = new ModelInitialzieListener();
EventManager::instance()->attach($listener);
<?php
use Cake\Event\EventListenerInterface;
class ModelInitialzieListener implements EventListenerInterface
{
public function implementedEvents()
{
return array(
'Model.initialize' => 'initializeEvent',
);
}
public function initializeEvent($event)
{
$table = $event->subject();
// do something here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment