Bundle/WidgetBundle/Renderer/WidgetRenderer.php
public function renderContainer(Widget $widget, View $view)
    {
        $dispatcher = $this->container->get('event_dispatcher');

        $dispatcher->dispatch(VictoireCmsEvents::WIDGET_PRE_RENDER, new WidgetRenderEvent($widget));

        $widgetMap = $widget->getWidgetMap();
        $directive = '';
        if ($this->container->get('security.authorization_checker')->isGranted('ROLE_VICTOIRE')) {
            $directive = 'widget';
        }

        $id = 'vic-widget-'.$widget->getId().'-container';

        $html = sprintf('<div %s widget-map="%s" id="%s" class="vic-widget-container" data-id="%s">', $directive, $widgetMap->getId(), $id, $widget->getId());

        if ($this->widgetHelper->isCacheEnabled($widget)) {
            $content = $this->widgetCache->fetch($widget);
            if (null === $content) {
                $content = $this->render($widget, $view);
                $this->widgetCache->save($widget, $content);
            } else {
                $this->victoireCollector->addCachedWidget($widget);
            }
        } else {
            $content = $this->render($widget, $view);
        }
        $html .= $content;
        $html .= '</div>'; //close container

        $dispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_RENDER, new WidgetRenderEvent($widget, $html));

        return $html;
    }
public function renderContainer(Widget $widget, View $view)
    {
        $dispatcher = $this->container->get('event_dispatcher');

        $dispatcher->dispatch(VictoireCmsEvents::WIDGET_PRE_RENDER, new WidgetRenderEvent($widget));

        $widgetMap = $widget->getWidgetMap();
        $directive = '';
        if ($this->container->get('security.authorization_checker')->isGranted('ROLE_VICTOIRE')) {
            $directive = 'widget';
        }

        $id = 'vic-widget-'.$widget->getId().'-container';

        $html = sprintf('<div %s widget-map="%s" id="%s" class="vic-widget-container" data-id="%s">', $directive, $widgetMap->getId(), $id, $widget->getId());

        if ($this->widgetHelper->isCacheEnabled($widget)) {
            $content = $this->widgetCache->fetch($widget);
            if (null === $content) {
                $content = $this->render($widget, $view);
                $this->widgetCache->save($widget, $content);
            } else {
                $this->victoireCollector->addCachedWidget($widget);
            }
        } else {
            $content = $this->render($widget, $view);
        }
        $html .= $content;
        $html .= '</div>'; //close container

        $dispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_RENDER, new WidgetRenderEvent($widget, $html));

        return $html;
    }
public function renderContainer ( Widget $ widget , View $ view ) { $ dispatcher = $ this -> container -> get ( 'event_dispatcher' ) ; $ dispatcher -> dispatch ( VictoireCmsEvents :: WIDGET_PRE_RENDER , new WidgetRenderEvent ( $ widget ) ) ; $ widgetMap = $ widget -> getWidgetMap ( ) ; $ directive = '' ; if ( $ this -> container -> get ( 'security.authorization_checker' ) -> isGranted ( 'ROLE_VICTOIRE' ) ) { $ directive = 'widget' ; } $ id = 'vic-widget-' . $ widget -> getId ( ) . '-container' ; $ html = sprintf ( '<div %s widget-map="%s" id="%s" class="vic-widget-container" data-id="%s">' , $ directive , $ widgetMap -> getId ( ) , $ id , $ widget -> getId ( ) ) ; if ( $ this -> widgetHelper -> isCacheEnabled ( $ widget ) ) { $ content = $ this -> widgetCache -> fetch ( $ widget ) ; if ( null === $ content ) { $ content = $ this -> render ( $ widget , $ view ) ; $ this -> widgetCache -> save ( $ widget , $ content ) ; } else { $ this -> victoireCollector -> addCachedWidget ( $ widget ) ; } } else { $ content = $ this -> render ( $ widget , $ view ) ; } $ html .= $ content ; $ html .= '</div>' ; //close container $ dispatcher -> dispatch ( VictoireCmsEvents :: WIDGET_POST_RENDER , new WidgetRenderEvent ( $ widget , $ html ) ) ; return $ html ; }
render a widget.

@param Widget $widget
@param View   $view

@return string
render a widget .