Bundle/WidgetBundle/Controller/WidgetController.php
public function deleteAction(Widget $widget, $viewReference)
    {
        $view = $this->getViewByReferenceId($viewReference);

        try {
            $widgetId = $widget->getId();
            $this->get('widget_manager')->deleteWidget($widget, $view);

            return new JsonResponse([
                    'success'  => true,
                    'message'  => $this->get('translator')->trans('victoire_widget.delete.success', [], 'victoire'),
                    'widgetId' => $widgetId,
                ]
            );
        } catch (Exception $ex) {
            return $this->getJsonReponseFromException($ex);
        }
    }
public function deleteAction(Widget $widget, $viewReference)
    {
        $view = $this->getViewByReferenceId($viewReference);

        try {
            $widgetId = $widget->getId();
            $this->get('widget_manager')->deleteWidget($widget, $view);

            return new JsonResponse([
                    'success'  => true,
                    'message'  => $this->get('translator')->trans('victoire_widget.delete.success', [], 'victoire'),
                    'widgetId' => $widgetId,
                ]
            );
        } catch (Exception $ex) {
            return $this->getJsonReponseFromException($ex);
        }
    }
public function deleteAction ( Widget $ widget , $ viewReference ) { $ view = $ this -> getViewByReferenceId ( $ viewReference ) ; try { $ widgetId = $ widget -> getId ( ) ; $ this -> get ( 'widget_manager' ) -> deleteWidget ( $ widget , $ view ) ; return new JsonResponse ( [ 'success' => true , 'message' => $ this -> get ( 'translator' ) -> trans ( 'victoire_widget.delete.success' , [ ] , 'victoire' ) , 'widgetId' => $ widgetId , ] ) ; } catch ( Exception $ ex ) { return $ this -> getJsonReponseFromException ( $ ex ) ; } }
Delete a Widget.

@param Widget $widget        The widget to delete
@param int    $viewReference The current view

@throws Exception

@return JsonResponse response
@Route("/victoire-dcms/widget/delete/{id}/{viewReference}", name="victoire_core_widget_delete", defaults={"_format": "json"})
Delete a Widget .