Closed Sysix closed 7 years ago
It shouldn't be possible that it returns null.
See the class used for events: https://github.com/fruux/sabre-event/blob/master/lib/EmitterTrait.php
You don't need the "&" beside $tag either, PHP objects are references by default.
You don't need the "&" beside $tag either, PHP objects are references by default.
Yeah I know, but for help to understand, that the object is changing.
It shouldn't be possible that it returns null.
I dont see a condition, which check for null. Only for false
The way you use events looks a bit unorthdox. Have you tried the documented way? Ie. something like:
public static function events(EventEmitter $eventEmitter)
{
$eventEmitter->on('beforeSave', function (Entity $entity, Mapper $mapper) {
/* checkParentForEmpty logic here, returning false cancels saving */
if ($entity->parent === '') {
$entity->parent = null;
}
return true;
});
}
I found the problem. It was really the Problem with the reference.
The Error-Message was not shown. After I die()
in the callback, I could debugging :)
Thanks for the help!
Hey guys, I tried so check my data before saving it into the database. I found that the Mapper has access to an Listener with callback-functions.
My code:
With XDebug I found, that on
EventEmitterTrait:emit
the result of the callback is always "null".What is with the code wrong?