Can't use PreDelete event


#1

Hi,

I am editing the TestListener under EventListener to do some automated stuff.
Now I want to do some stuff before deleting an Object.

To inject my code when saving I use the following:

public function onObjectPreUpdate(DataObjectEvent $event)
{
//Stuff
}

This works fine.
But when using the following, nothing happens:

public function onObjectPreDelete(DataObjectEvent $event)
{
//Stuff
}

For testing purposes I implemented a Logger-call as the first part of code inside this function but not even the Logfile is created.
To me it looks like the code is completely ignored!

Can you explain this to me??

Cheers


#2

Had you define tags in services.yml?


#3

No but I did never define a tag for PreUpdate oder PostAdd (which I use too).

But I just tried it and it didn’t change anything…


#4

Could you please post getSubscribedEvents method?


#5
public static function getSubscribedEvents()
{
    return [
        DataObjectEvents::PRE_UPDATE => 'onObjectPreUpdate',
        DataObjectEvents::PRE_ADD => 'onObjectPostAdd',
        DataObjectEvents::PRE_DELETE => 'onObjectPreDelete'
    ];
}

#6

Can you check whether it executes \Pimcore\Model\DataObject\AbstractObject::delete?
There should be line like this:

 \Pimcore::getEventDispatcher()->dispatch(DataObjectEvents::PRE_DELETE, new DataObjectEvent($this));

#7

Can I check this in my prod.log? if not where can I find it?


#9

problem still occurs