Skip to content

Commit

Permalink
Merge 94c53cd into ff905e1
Browse files Browse the repository at this point in the history
  • Loading branch information
nilov committed Sep 19, 2017
2 parents ff905e1 + 94c53cd commit ea23f2b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,20 @@ public function listAction()
*
* @throws AccessDeniedException If access is not granted
*/
public function batchActionDelete(ProxyQueryInterface $query)
public function batchActionDelete(ProxyQueryInterface $query = null)
{
$this->admin->checkAccess('batchDelete');

$modelManager = $this->admin->getModelManager();
if ($query) {
$modelManager = $this->admin->getModelManager();

try {
$modelManager->batchDelete($this->admin->getClass(), $query);
$this->addFlash('sonata_flash_success', 'flash_batch_delete_success');
} catch (ModelManagerException $e) {
$this->handleModelManagerException($e);
$this->addFlash('sonata_flash_error', 'flash_batch_delete_error');
try {
$modelManager->batchDelete($this->admin->getClass(), $query);
$this->addFlash('sonata_flash_success', 'flash_batch_delete_success');
} catch (ModelManagerException $e) {
$this->handleModelManagerException($e);
$this->addFlash('sonata_flash_error', 'flash_batch_delete_error');
}
}

return new RedirectResponse($this->admin->generateUrl(
Expand Down

0 comments on commit ea23f2b

Please sign in to comment.