Reputation: 187
i've created an admin panel with Sonata (Symfony2 Bundle http://sonata-project.org/about) and i've added an event in the preRemove hook (Doctrine).
In few words when i delete a record, run a curl to an other service. Everythings works.
But Sonata have also the "Batch Operations" where i can select multiple lines and choose "Delete all selected".
But, if i choose "delete all selected" the curl not started. The preRemove hook (Doctrine) it's not called.
There is someone that can help me?!
Thanks
Upvotes: 4
Views: 1915
Reputation: 762
There is another option, you can use the preBatchAction hook in your admin class.
public function preBatchAction($actionName, ProxyQueryInterface $query, array & $idx, $allElements)
{
if ($actionName == 'delete') {
// logic here
}
}
Upvotes: 2
Reputation: 2796
It seems, that batch delete action really avoids calling preRemove
method (see Sonata\AdminBundle\Controller\CRUDController::batchActionDelete
which calls Sonata\DoctrineORMAdminBundle\Model\ModelManager::batchDelete
).
However, you have options:
batchActionDelete
by using custom controller extending CRUDController
. SonataMediaBundle does that.Upvotes: 2