public function render(Widget $widget, View $view)
    {
        //the mode of display of the widget
        $mode = $widget->getMode();

        //if entity is given and it's not the object, retrieve it and set the entity for the widget
        if ($mode == Widget::MODE_BUSINESS_ENTITY && $view instanceof BusinessPage) {
            $widget->setEntity($view->getBusinessEntity());
        } elseif ($view instanceof BusinessTemplate) {
            //We'll try to find a sample entity to mock the widget behavior
            /** @var EntityManager $entityManager */
            $entityManager = $this->container->get('doctrine.orm.entity_manager');
            if ($mock = $this->bepHelper->getEntitiesAllowedQueryBuilder($view, $entityManager)->setMaxResults(1)->getQuery()->getOneOrNullResult()) {
                $widget->setEntity($mock);
            }
        }

        //the templating service
        $templating = $this->container->get('templating');

        //the content of the widget

        $parameters = $this->container->get('victoire_widget.widget_content_resolver')->getWidgetContent($widget);
        /*
         * In some cases, for example, WidgetRender in BusinessEntity mode with magic variables {{entity.id}} transformed
         * into the real business entity id, then if in the rendered action, we need to flush, it would persist the
         * modified widget which really uncomfortable ;)
         */
        if ($widget->getMode() == Widget::MODE_BUSINESS_ENTITY) {
            $this->container->get('doctrine.orm.entity_manager')->refresh($widget);
        }

        //the template displayed is in the widget bundle (with the potential theme)
        $showView = 'show'.ucfirst($widget->getTheme());
        $templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName($showView, $widget);

        return $templating->render($templateName, $parameters);
    }