소스 검색

Added isXmlHttp check

Wesley van Opdorp 12 년 전
부모
커밋
2e89b6155c
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      Controller/CRUDController.php

+ 11 - 0
Controller/CRUDController.php

@@ -214,8 +214,19 @@ class CRUDController extends Controller
         if ($this->getRequest()->getMethod() == 'DELETE') {
             try {
                 $this->admin->delete($object);
+
+                if ($this->isXmlHttpRequest()) {
+                    return $this->renderJson(array('result' => 'ok'));
+                }
+
                 $this->get('session')->setFlash('sonata_flash_success', 'flash_delete_success');
+
             } catch (ModelManagerException $e) {
+
+                if ($this->isXmlHttpRequest()) {
+                    return $this->renderJson(array('result' => 'error'));
+                }
+
                 $this->get('session')->setFlash('sonata_flash_error', 'flash_delete_error');
             }