Bundle/WidgetBundle/Controller/WidgetController.php
public function apiWidgetsAction($widgetIds, $viewReferenceId)
    {
        $view = $this->get('victoire_page.page_helper')->findPageByParameters(['id' => $viewReferenceId]);
        $response = [];
        $widgets = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireWidgetBundle:Widget')
            ->findBy(['id' => json_decode($widgetIds)]);

        foreach ($widgets as $widget) {
            $response[$widget->getId()] = $this->get('victoire_widget.widget_renderer')->render($widget, $view);
        }

        return new JsonResponse($response);
    }
public function apiWidgetsAction($widgetIds, $viewReferenceId)
    {
        $view = $this->get('victoire_page.page_helper')->findPageByParameters(['id' => $viewReferenceId]);
        $response = [];
        $widgets = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireWidgetBundle:Widget')
            ->findBy(['id' => json_decode($widgetIds)]);

        foreach ($widgets as $widget) {
            $response[$widget->getId()] = $this->get('victoire_widget.widget_renderer')->render($widget, $view);
        }

        return new JsonResponse($response);
    }
public function apiWidgetsAction ( $ widgetIds , $ viewReferenceId ) { $ view = $ this -> get ( 'victoire_page.page_helper' ) -> findPageByParameters ( [ 'id' => $ viewReferenceId ] ) ; $ response = [ ] ; $ widgets = $ this -> get ( 'doctrine.orm.entity_manager' ) -> getRepository ( 'VictoireWidgetBundle:Widget' ) -> findBy ( [ 'id' => json_decode ( $ widgetIds ) ] ) ; foreach ( $ widgets as $ widget ) { $ response [ $ widget -> getId ( ) ] = $ this -> get ( 'victoire_widget.widget_renderer' ) -> render ( $ widget , $ view ) ; } return new JsonResponse ( $ response ) ; }
API widgets function.

@param string $widgetIds       the widget ids to fetch in json
@param int    $viewReferenceId

@throws \Victoire\Bundle\ViewReferenceBundle\Exception\ViewReferenceNotFoundException

@Route("/victoire-dcms-public/api/widgets/{widgetIds}/{viewReferenceId}", name="victoire_core_widget_apiWidgets", options={"expose"=true})

@return JsonResponse
API widgets function .