Where to put Event listener to detect afterSave of plugin table


#1

I’m on CakePHP 3.3.16
I’ve put this in the main app’s Bootstrap.php:

    Log::write('info','foo');
    $contactTable = \Cake\ORM\TableRegistry::get('Contacts.contacts');
    $contactTable->eventManager()
           ->on('Model.afterSave', ['priority' => 1],function($event, $entity)
           {
               pr( "afterSave - " );
               Log::write('info','afterSave');
               
           });

I get “foo” and when I save the plugin model in question, there’s nothing in the logs.

Do I need to update CakePHP? I think a method has been depracated?


#2

Any one (bump)? Is there a difference between:

$contactTable = \Cake\ORM\TableRegistry::get('Contacts.contacts');

and

$contactTable = \Cake\ORM\TableRegistry::get('Contacts.Contacts');

#3

From the docs https://api.cakephp.org/3.5/class-Cake.ORM.TableRegistry.html#_get It seems like the first parm is just a string, but by convention I think field names as usually lower case.