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

        try {
            $this->get('victoire_widget.widget_helper')->deleteById($id);
            $this->get('doctrine.orm.entity_manager')->flush();

            if ($view instanceof Template) {
                $redirect = $this->generateUrl('victoire_template_show', ['id' => $view->getId()]);
            } elseif ($view instanceof BusinessTemplate) {
                $redirect = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
            } else {
                $viewReference = $this->get('victoire_view_reference.repository')
                    ->getOneReferenceByParameters(['viewId' => $view->getId()]);

                $redirect = $this->generateUrl('victoire_core_page_show', [
                        'url' => $viewReference->getUrl(),
                    ]);
            }

            return new JsonResponse([
                    'success'  => true,
                    'redirect' => $redirect,
                ]);
        } catch (Exception $ex) {
            return $this->getJsonReponseFromException($ex);
        }
    }
public function unlinkAction($id, $viewReference)
    {
        $view = $this->getViewByReferenceId($viewReference);

        try {
            $this->get('victoire_widget.widget_helper')->deleteById($id);
            $this->get('doctrine.orm.entity_manager')->flush();

            if ($view instanceof Template) {
                $redirect = $this->generateUrl('victoire_template_show', ['id' => $view->getId()]);
            } elseif ($view instanceof BusinessTemplate) {
                $redirect = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
            } else {
                $viewReference = $this->get('victoire_view_reference.repository')
                    ->getOneReferenceByParameters(['viewId' => $view->getId()]);

                $redirect = $this->generateUrl('victoire_core_page_show', [
                        'url' => $viewReference->getUrl(),
                    ]);
            }

            return new JsonResponse([
                    'success'  => true,
                    'redirect' => $redirect,
                ]);
        } catch (Exception $ex) {
            return $this->getJsonReponseFromException($ex);
        }
    }
public function unlinkAction ( $ id , $ viewReference ) { $ view = $ this -> getViewByReferenceId ( $ viewReference ) ; try { $ this -> get ( 'victoire_widget.widget_helper' ) -> deleteById ( $ id ) ; $ this -> get ( 'doctrine.orm.entity_manager' ) -> flush ( ) ; if ( $ view instanceof Template ) { $ redirect = $ this -> generateUrl ( 'victoire_template_show' , [ 'id' => $ view -> getId ( ) ] ) ; } elseif ( $ view instanceof BusinessTemplate ) { $ redirect = $ this -> generateUrl ( 'victoire_business_template_show' , [ 'id' => $ view -> getId ( ) ] ) ; } else { $ viewReference = $ this -> get ( 'victoire_view_reference.repository' ) -> getOneReferenceByParameters ( [ 'viewId' => $ view -> getId ( ) ] ) ; $ redirect = $ this -> generateUrl ( 'victoire_core_page_show' , [ 'url' => $ viewReference -> getUrl ( ) , ] ) ; } return new JsonResponse ( [ 'success' => true , 'redirect' => $ redirect , ] ) ; } catch ( Exception $ ex ) { return $ this -> getJsonReponseFromException ( $ ex ) ; } }
Unlink a Widget by id
-> used to unlink an invalid widget after a bad widget unplug.

@param int $id            The widgetId to unlink
@param int $viewReference The current viewReference

@throws Exception

@return JsonResponse response
@Route("/victoire-dcms/widget/unlink/{id}/{viewReference}", name="victoire_core_widget_unlink", defaults={"_format": "json"}, options={"expose"=true})
Unlink a Widget by id - > used to unlink an invalid widget after a bad widget unplug .