Bundle/WidgetBundle/Controller/WidgetController.php
public function newAction(Request $request, $type, $viewReference, $slot = null, $quantum = 'a')
    {
        try {
            $view = $this->getViewByReferenceId($viewReference);

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

            $position = $request->query->has('position') ? $request->query->get('position') : null;
            $parentWidgetMap = $request->query->has('parentWidgetMap') ? $request->query->get('parentWidgetMap') : null;
            $widgetData = $this->get('victoire_widget.widget_manager')->newWidget(
                Widget::MODE_STATIC,
                $type,
                $slot,
                $view,
                $position,
                $parentWidgetMap,
                $quantum
            );

            $response = new JsonResponse([
                'success' => true,
                'html'    => $widgetData['html'],
            ]);
        } catch (Exception $ex) {
            $response = $this->getJsonReponseFromException($ex);
        }

        return $response;
    }
public function newAction(Request $request, $type, $viewReference, $slot = null, $quantum = 'a')
    {
        try {
            $view = $this->getViewByReferenceId($viewReference);

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

            $position = $request->query->has('position') ? $request->query->get('position') : null;
            $parentWidgetMap = $request->query->has('parentWidgetMap') ? $request->query->get('parentWidgetMap') : null;
            $widgetData = $this->get('victoire_widget.widget_manager')->newWidget(
                Widget::MODE_STATIC,
                $type,
                $slot,
                $view,
                $position,
                $parentWidgetMap,
                $quantum
            );

            $response = new JsonResponse([
                'success' => true,
                'html'    => $widgetData['html'],
            ]);
        } catch (Exception $ex) {
            $response = $this->getJsonReponseFromException($ex);
        }

        return $response;
    }
public function newAction ( Request $ request , $ type , $ viewReference , $ slot = null , $ quantum = 'a' ) { try { $ view = $ this -> getViewByReferenceId ( $ viewReference ) ; if ( ! $ reference = $ this -> get ( 'victoire_view_reference.repository' ) -> getOneReferenceByParameters ( [ 'id' => $ viewReference ] ) ) { $ reference = new ViewReference ( $ viewReference ) ; } $ view -> setReference ( $ reference ) ; $ position = $ request -> query -> has ( 'position' ) ? $ request -> query -> get ( 'position' ) : null ; $ parentWidgetMap = $ request -> query -> has ( 'parentWidgetMap' ) ? $ request -> query -> get ( 'parentWidgetMap' ) : null ; $ widgetData = $ this -> get ( 'victoire_widget.widget_manager' ) -> newWidget ( Widget :: MODE_STATIC , $ type , $ slot , $ view , $ position , $ parentWidgetMap , $ quantum ) ; $ response = new JsonResponse ( [ 'success' => true , 'html' => $ widgetData [ 'html' ] , ] ) ; } catch ( Exception $ ex ) { $ response = $ this -> getJsonReponseFromException ( $ ex ) ; } return $ response ; }
New Widget.

@param Request $request
@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  $quantum       The quantum letter used to avoid same form name

@throws Exception

@return JsonResponse
@Route("/victoire-dcms/widget/new/{type}/{viewReference}/{slot}/{quantum}", name="victoire_core_widget_new", defaults={"slot":null, "quantum":"a"}, options={"expose"=true})
New Widget .