This method build widgetmaps relativly to given view and it's templates.

@param View $view
@param bool $updatePage

@return array
197469
public function build(View $view, $updatePage = true)
    {
        $builtWidgetMap = [];

        $widgetMaps = $this->contextualViewWarmer->warm($view);

        $slots = $this->removeOverwritedWidgetMaps($widgetMaps);

        $this->removeDeletedWidgetMaps($slots);

        foreach ($slots as $slot => $slotWidgetMaps) {
            $mainWidgetMap = null;
            $builtWidgetMap[$slot] = [];

            $rootWidgetMap = $this->findRootWidgetMap($slotWidgetMaps);

            if ($rootWidgetMap) {
                $builtWidgetMap[$slot][] = $rootWidgetMap;
                $builtWidgetMap = $this->orderizeWidgetMap($rootWidgetMap, $builtWidgetMap, $slot, $slotWidgetMaps, $view);
            }
        }

        if ($updatePage) {
            $view->setBuiltWidgetMap($builtWidgetMap);
        }

        return $builtWidgetMap;
    }
326850
public function setView($view)
    {

        if (class_exists($view)) {
            //if we already have a default view
            $values = [];

            //grab all its parameters and store in parameters
            if (isset($this->view) && $this->view instanceof View) {

                $values = $this->view->getDataArray();
                $layout = $this->view->getLayout();

                //Load the newView;
                $this->view = $this->loadView($view, $values);

                if (!empty($layout)) {
                    $this->view->setLayout($layout);
                }
            }

            return $this;

        } else if (is_string($view)) {

            $this->response->addContent($view); //so that $this->view("Hi There");  will output Hi There;

            return $this;

        }

        return false; //no view set;
    }
1157173
function View(template) {
  this.context = null;
  if (!template) template = this;
  this.template = template;
  if (!this.template.bindings) this.template.bindings = [];
  this.bindings = this.template.bindings.map(mapBinding.bind(this), this);

  this.firstViewNode = this.firstChild;
  this.lastViewNode = this.lastChild;
  if (this.firstViewNode) {
    this.firstViewNode.view = this;
    this.lastViewNode.view = this;
  }
}
843985
private function getListTemplateFromConfigName($viewName)
    {
        if (isset($this->viewToListViewMapping[$viewName])) {
            return $this->viewToListViewMapping[$viewName];
        }

        return current($this->viewToListViewMapping);
    }
877394
public function warm(View $viewToWarm, View $contextualView = null)
    {
        $widgetMaps = [];

        if (null === $contextualView) {
            $contextualView = $viewToWarm;
        }

        foreach ($viewToWarm->getWidgetMaps() as $_widgetMap) {
            $_widgetMap->setContextualView($contextualView);
            $widgetMaps[] = $_widgetMap;
        }

        if ($template = $viewToWarm->getTemplate()) {
            $templateWidgetMaps = $this->warm($template, $contextualView);
            $widgetMaps = array_merge($widgetMaps, $templateWidgetMaps);
        }

        return $widgetMaps;
    }
603062
public function widgetPlugin($params, $view)
    {
        extract($params);
        if (isset($name)) {
            if (class_exists($name)) {
                $widget = new $name;
                if ($widget instanceof IWidget) {
                    return $widget->exec($params, $view);
                }
            }
        }
    }
1055705
public function render(View $view)
    {
        $this->eventDispatcher->dispatch(
            MVCEvents::PRE_CONTENT_VIEW,
            new PreContentViewEvent($view)
        );

        $templateIdentifier = $view->getTemplateIdentifier();
        if ($templateIdentifier instanceof Closure) {
            return $templateIdentifier($view->getParameters());
        }

        if ($view->getTemplateIdentifier() === null) {
            throw new NoViewTemplateException($view);
        }

        return $this->templateEngine->render(
            $view->getTemplateIdentifier(),
            $view->getParameters()
        );
    }
1098836
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;
    }
274367
public function deleteWidget(Widget $widget, View $view)
    {
        //we update the widget map of the view
        $this->widgetMapBuilder->build($view);
        $widgetMap = $widget->getWidgetMap();
        //the widget is removed only if the current view is the view of the widget
        if ($widgetMap->getView() == $view && $widgetMap->getAction() != WidgetMap::ACTION_DELETE) {
            //we remove the widget
            $this->entityManager->remove($widget);
        }

        //update the view deleting the widget
        $this->widgetMapManager->delete($view, $widget);

        //we update the view
        $this->entityManager->persist($view);

        $this->entityManager->flush();
    }
54218
public function render($view = false, $layout = false)
    {
        if ($layout !== false) {
            $this->setLayout($layout);
        }

        if ($view !== false) {
            $this->setView($view);
        }

        return $this->bufferResponse();
    }
237675
public function setViewParams($view)
    {
        
        foreach ($this->url as $url) {
            if(isset($view->params['urls']) && is_array($view->params['urls'])){
                $view->params['urls'] = $this->MenuMerge($view->params['urls'],$url);
            }else{
                $view->params['urls'] = $url;
            }
            
        }
        
        if($module = $this->getModule()){
            $view->params['urls'][$module]['active']=true;
        }
    }
1050763
public function resolve($template, $view = null)
    {
        if (!$template) {
            return '';
        }

        $segments = explode('/', $template);
        $page = end($segments);

        foreach ($this->baseDirectories as $dirs) {
            foreach ($dirs as $dir) {
                if ($t = $this->tryTemplate($dir, $template, $view)) {
                    return $t;
                }

                if ($t = $this->tryTemplate($dir, $template.$this->extension, $view)) {
                    return $t;
                }
            }
        }

        if ($template[0] !== '_') {

            foreach ($this->baseDirectories as $dirs) {
                foreach ($dirs as $dir) {
                    if ($t = $this->tryTemplate($dir, 'shared'.DIRECTORY_SEPARATOR.$page, $view)) {
                        return $t;
                    }

                    if ($t = $this->tryTemplate($dir, 'shared'.DIRECTORY_SEPARATOR.$page.$this->extension, $view)) {
                        return $t;
                    }
                }
            }

        }

    }
419865
public function getAvailablePosition(View $view)
    {
        $widgetMaps = $view->getBuiltWidgetMap();

        $availablePositions = [];
        foreach ($widgetMaps as $slot => $widgetMap) {
            foreach ($widgetMap as $_widgetMap) {
                $availablePositions[$slot][$_widgetMap->getId()]['id'] = $_widgetMap->getId();
                $availablePositions[$slot][$_widgetMap->getId()][WidgetMap::POSITION_BEFORE] = true;
                $availablePositions[$slot][$_widgetMap->getId()][WidgetMap::POSITION_AFTER] = true;
                if ($_widgetMap->getReplaced()) {
                    $availablePositions[$slot][$_widgetMap->getId()]['replaced'] = $_widgetMap->getReplaced()->getId();
                }
            }
            /** @var WidgetMap $_widgetMap */
            foreach ($widgetMap as $_widgetMap) {
                if ($_widgetMap->getParent()) {
                    if ($substitute = $_widgetMap->getParent()->getSubstituteForView($view)) {
                        $availablePositions[$slot][$substitute->getId()][$_widgetMap->getPosition()] = false;
                    } else {
                        $availablePositions[$slot][$_widgetMap->getParent()->getId()][$_widgetMap->getPosition()] = false;
                    }
                }
            }
        }

        return $availablePositions;
    }
189379
public function cmsWidgetUnlinkAction($widgetId, $view)
    {
        $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters(
            ['viewId' => $view->getId()]
        );
        if (!$viewReference && $view->getId() != '') {
            $viewReference = new ViewReference($view->getId());
        } elseif ($view instanceof VirtualBusinessPage) {
            $viewReference = new ViewReference($view->getTemplate()->getId());
        }

        $view->setReference($viewReference);

        return $this->widgetRenderer->renderUnlinkActionByWidgetId($widgetId, $view);
    }
1218880
public function template($template = false, $layout = null)
    {
        if ($template === false) {
            return [
                'template' => $this->_template,
                'layout' => $this->_layout,
            ];
        }
        $this->_template = $template;
        if ($layout !== null) {
            $this->_layout = $layout;
        }

        return $this;
    }
669871
protected function getViewModuleFiles($view)
    {
        $rootPath = resource_path('views/' . str_replace('.', '/', $view));

        return [
            $rootPath . '/index',
            $rootPath . '/show',
            $rootPath . '/create',
            $rootPath . '/edit'
        ];
    }
1213225
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);
    }