Bundle/WidgetBundle/Controller/WidgetController.php
public function createAction($mode, $type, $viewReference, $slot = null, $position = null, $parentWidgetMap = null, $businessEntityId = null, $quantum = null)
    {
        try {
            //services
            $view = $this->getViewByReferenceId($viewReference);

            $isNewPage = $view->getId() === null ? true : false;

            if (!$reference = $this->get('victoire_view_reference.repository')
                ->getOneReferenceByParameters(['id' => $viewReference])) {
                $reference = new ViewReference($viewReference);
            }

            $view->setReference($reference);
            $this->get('victoire_core.current_view')->setCurrentView($view);

            $this->congrat($this->get('translator')->trans('victoire.success.message', [], 'victoire'));
            $response = $this->get('widget_manager')->createWidget($mode, $type, $slot, $view, $businessEntityId, $position, $parentWidgetMap, $quantum);

            if ($isNewPage) {
                $response = new JsonResponse([
                    'success'  => true,
                    'redirect' => $this->generateUrl(
                        'victoire_core_page_show',
                        [
                            'url' => $reference->getUrl(),
                        ]
                    ),
                ]);
            } else {
                $response = new JsonResponse($response);
            }
        } catch (Exception $ex) {
            $response = $this->getJsonReponseFromException($ex);
        }

        return $response;
    }
public function createAction($mode, $type, $viewReference, $slot = null, $position = null, $parentWidgetMap = null, $businessEntityId = null, $quantum = null)
    {
        try {
            //services
            $view = $this->getViewByReferenceId($viewReference);

            $isNewPage = $view->getId() === null ? true : false;

            if (!$reference = $this->get('victoire_view_reference.repository')
                ->getOneReferenceByParameters(['id' => $viewReference])) {
                $reference = new ViewReference($viewReference);
            }

            $view->setReference($reference);
            $this->get('victoire_core.current_view')->setCurrentView($view);

            $this->congrat($this->get('translator')->trans('victoire.success.message', [], 'victoire'));
            $response = $this->get('widget_manager')->createWidget($mode, $type, $slot, $view, $businessEntityId, $position, $parentWidgetMap, $quantum);

            if ($isNewPage) {
                $response = new JsonResponse([
                    'success'  => true,
                    'redirect' => $this->generateUrl(
                        'victoire_core_page_show',
                        [
                            'url' => $reference->getUrl(),
                        ]
                    ),
                ]);
            } else {
                $response = new JsonResponse($response);
            }
        } catch (Exception $ex) {
            $response = $this->getJsonReponseFromException($ex);
        }

        return $response;
    }
public function createAction ( $ mode , $ type , $ viewReference , $ slot = null , $ position = null , $ parentWidgetMap = null , $ businessEntityId = null , $ quantum = null ) { try { //services $ view = $ this -> getViewByReferenceId ( $ viewReference ) ; $ isNewPage = $ view -> getId ( ) === null ? true : false ; if ( ! $ reference = $ this -> get ( 'victoire_view_reference.repository' ) -> getOneReferenceByParameters ( [ 'id' => $ viewReference ] ) ) { $ reference = new ViewReference ( $ viewReference ) ; } $ view -> setReference ( $ reference ) ; $ this -> get ( 'victoire_core.current_view' ) -> setCurrentView ( $ view ) ; $ this -> congrat ( $ this -> get ( 'translator' ) -> trans ( 'victoire.success.message' , [ ] , 'victoire' ) ) ; $ response = $ this -> get ( 'widget_manager' ) -> createWidget ( $ mode , $ type , $ slot , $ view , $ businessEntityId , $ position , $ parentWidgetMap , $ quantum ) ; if ( $ isNewPage ) { $ response = new JsonResponse ( [ 'success' => true , 'redirect' => $ this -> generateUrl ( 'victoire_core_page_show' , [ 'url' => $ reference -> getUrl ( ) , ] ) , ] ) ; } else { $ response = new JsonResponse ( $ response ) ; } } catch ( Exception $ ex ) { $ response = $ this -> getJsonReponseFromException ( $ ex ) ; } return $ response ; }
Create a widget.
This action needs 2 routes to handle the presence or not of "businessEntityId" and 'parentWidgetMap'
that are both integers but "businessEntityId" present only in !static mode.

@param string $type             The type of the widget we edit
@param int    $viewReference    The view reference where attach the widget
@param string $slot             The slot where attach the widget
@param string $businessEntityId The BusinessEntity::id (can be null if the submitted form is in static mode)

@throws Exception

@return Response|JsonResponse
@Route("/victoire-dcms/widget/create/static/{type}/{viewReference}/{slot}/{quantum}/{position}/{parentWidgetMap}", name="victoire_core_widget_create_static", defaults={"mode":"static", "slot":null, "businessEntityId":null, "position":null, "parentWidgetMap":null, "_format": "json", "quantum":"a"})
@Route("/victoire-dcms/widget/create/{mode}/{type}/{viewReference}/{slot}/{quantum}/{businessEntityId}/{position}/{parentWidgetMap}", name="victoire_core_widget_create", defaults={"slot":null, "businessEntityId":null, "position":null, "parentWidgetMap":null, "_format": "json", "quantum":"a"})
Create a widget . This action needs 2 routes to handle the presence or not of businessEntityId and parentWidgetMap that are both integers but businessEntityId present only in !static mode .