Closed xavier83ar closed 7 years ago
We're using it in production, are you working in plugins or only in src? We have the auth magic happening in controller.initialize if that changes anything.
Well, I feel somewhat fool. In order to recreate the issue and provide a (not) working example, I've created a fresh new cakephp project from composer, created some basic database schema and added footprint plugin... and voalá, it's worked. So, I guess the issue is in my other project.
Nevertheless, I should mention that to make FootprintBehavior::beforeFind
callback to work I had to dig in into plugin's code because I didn't found it in documentation. Using a user_id field to track "owner", behavior setup looks something like this:
$this->addBehavior('Muffin/Footprint.Footprint', [
'events' => [
'Model.beforeSave' => [
'user_id' => 'new',
],
'Model.beforeFind' => [
'user_id' => '_footprint.id'
]
],
]);
I leave the example here as may be usefull for someone else.
Could you add it to https://github.com/UseMuffin/Footprint/blob/master/README.md ?
I've installed and set it up, everything seems to be ok, the user is properly loaded into
FootprintAwareTrait::_currentUserInstance
but_footprint
option key is empty whenModel.beforeSave
happens.I've debugging it (with xdebug) and it seems that
FootprintListener::handleEvent
gets fired after Model.beforeSave, so then '_footprint' option key gets populated with current user, but it's useless as Model events already happened.I don't know if I'm doing something wrong or what, there is no config issues, no error, just it doesn't work. Does anybody get this plugin working?