Inject Widgets in View's builtWidgetMap.

@param View $view
@param $viewWidgets
485180
private function injectWidgets(View $view, $viewWidgets)
    {
        $builtWidgetMap = $view->getBuiltWidgetMap();

        foreach ($builtWidgetMap as $slot => $widgetMaps) {
            foreach ($widgetMaps as $i => $widgetMap) {
                foreach ($viewWidgets as $widget) {
                    if ($widget->getWidgetMap() == $widgetMap) {
                        $builtWidgetMap[$slot][$i]->addWidget($widget);

                        //Override Collection default behaviour to avoid useless query
                        $builtWidgetMap[$slot][$i]->getWidgets()->setDirty(false);
                        $builtWidgetMap[$slot][$i]->getWidgets()->setInitialized(true);
                        continue;
                    }
                }
            }
        }

        $view->setBuiltWidgetMap($builtWidgetMap);
    }
376651
function(view, config, widget) {

		this._view = view;
		//this._config = config;
		this._widget = widget;

		this._start_script_id = 'c' + view.guid + 's';
		this._end_script_id = 'c' + view.guid + 'e';

	}
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;
    }
1282181
public function onAdd(ViewInterface $view)
    {
        if (!$view instanceof TwigView) {
            throw new \InvalidArgumentException("This plugin only works with a Twig view");
        }
        
        foreach ($this->extensions as $class) {
            if (class_exists($class)) {
                $view->getTwig()->addExtension(new $class());
            }
        }
    }
1252
public function compose(View $view)
    {
        $displayMetrics = $this->config->get('setting.display_graphs');
        $metrics = $this->getVisibleMetrics($displayMetrics);

        $view->withDisplayMetrics($displayMetrics)
            ->withMetrics($metrics);
    }
714391
public function buildWidgetForm(Widget $widget, View $view, $businessEntityId = null, $namespace = null, $formMode = Widget::MODE_STATIC, $position = null, $parentWidgetMap = null, $slotId = null, $quantum = null)
    {
        $router = $this->container->get('router');

        //test parameters
        if ($businessEntityId !== null) {
            if ($namespace === null) {
                throw new \Exception('The namespace is mandatory if the businessEntityId is given');
            }
            if (in_array($formMode, [Widget::MODE_STATIC, null])) {
                throw new \Exception('The formMode cannot be null or static if the businessEntityId is given');
            }
        }

        $container = $this->container;
        $formFactory = $container->get('form.factory');

        //are we updating or creating the widget?
        if ($widget->getId() === null) {
            $viewReference = $view->getReference();
            $actionParams = [
                'viewReference'   => $viewReference->getId(),
                'slot'            => $slotId,
                'type'            => $widget->getType(), // @todo: use the config
                'position'        => $position,
                'parentWidgetMap' => $parentWidgetMap,
                'quantum'         => $quantum,
            ];
            $action = 'victoire_core_widget_create';
            if ($businessEntityId) {
                $actionParams['businessEntityId'] = $businessEntityId;
                $actionParams['mode'] = $formMode;
            } else {
                $action = 'victoire_core_widget_create_static';
            }
            $formUrl = $router->generate($action, $actionParams);
        } else {
            $viewReference = $this->container->get('victoire_core.current_view')->getCurrentView()->getReference();
            $formUrl = $router->generate('victoire_core_widget_update',
                [
                    'id'               => $widget->getId(),
                    'viewReference'    => $viewReference->getId(),
                    'businessEntityId' => $businessEntityId,
                    'mode'             => $formMode,
                    'quantum'          => $quantum,
                ]
            );
        }

        $widgetName = $this->container->get('victoire_widget.widget_helper')->getWidgetName($widget);

        $widgetFormTypeClass = ClassUtils::getClass(
            $this->container->get(
                sprintf(
                    'victoire.widget.form.%s',
                    strtolower($widgetName)
                )
            )
        );

        $optionsContainer = new WidgetOptionsContainer([
            'businessEntityId' => $businessEntityId,
            'namespace'        => $namespace,
            'mode'             => $formMode,
            'quantum'          => $quantum,
            'action'           => $formUrl,
            'method'           => 'POST',
            'dataSources'      => $this->container->get('victoire_criteria.chain.data_source_chain'),
        ]);

        $event = new WidgetFormPreCreateEvent($optionsContainer, $widgetFormTypeClass);
        $this->container->get('event_dispatcher')->dispatch(WidgetFormEvents::PRE_CREATE, $event);
        $this->container->get('event_dispatcher')->dispatch(WidgetFormEvents::PRE_CREATE.'_'.strtoupper($widgetName), $event);

        /** @var Form $mockForm Get the base form to get the name */
        $mockForm = $formFactory->create($widgetFormTypeClass, $widget, $optionsContainer->getOptions());
        //Prefix base name with form mode to avoid to have unique form fields ids

        $builder = $formFactory->createNamed(
            sprintf('%s_%s_%s_%s', $businessEntityId, $quantum, $formMode, $mockForm->getName()),
            $widgetFormTypeClass,
            $widget,
            $optionsContainer->getOptions()
        );

        $event = new WidgetFormPostCreateEvent($builder);
        $this->container->get('event_dispatcher')->dispatch(WidgetFormEvents::POST_CREATE, $event);
        $this->container->get('event_dispatcher')->dispatch(WidgetFormEvents::POST_CREATE.'_'.strtoupper($widgetName), $event);

        return $builder;
    }
521609
public function addWidgetMap(WidgetMap $widgetMap)
    {
        if (!$widgetMap->getView()) {
            $widgetMap->setView($this);
        }
        $this->widgetMaps[] = $widgetMap;
    }
862649
public function dropAndCreateView(View $view)
    {
        $this->tryMethod('dropView', $view->getQuotedName($this->_platform));
        $this->createView($view);
    }
540698
public function compose(View $view)
    {
        $view->with('tagsRatios', $this->prepareRatios(
            $this->cachedTags()->load(['posts'])
        ));
    }
444226
public function setWidgets(array $widgets)
    {
        $this->widgets = [];

        foreach ($widgets as $widgetIdent => $widget) {
            $this->addWidget($widgetIdent, $widget);
        }

        return $this;
    }
379571
public function setWidgetMap(WidgetMap $widgetMap = null)
    {
        if ($widgetMap) {
            $widgetMap->addWidget($this);
        }
        $this->widgetMap = $widgetMap;

        return $this;
    }
591154
@Override
    protected void defineWidgets() {

        initModule();

        addWidget(new CmsWidgetDialogParameter(m_dependency, "name", PAGES[0], new CmsDisplayWidget()));
        addWidget(new CmsWidgetDialogParameter(m_dependency, "version.version", PAGES[0], new CmsDisplayWidget()));

    }
1122325
public function setViewPath($view)
    {
        $this->layout->layout = $this->viewPath->setUp($this->layout->layout, $view);

        return $this;
    }
202084
protected function initializeView(ViewInterface $view)
    {
        $view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
        parent::initializeView($view);
    }
215297
public function onAdd(ViewInterface $view)
    {
        $this->assertView($view);

        $view->getTwig()->addExtension($this->createExtension());
    }
872646
protected function registerScripts(\yii\web\View $view){
        if ($this->clientOptions !== false) {
            $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
            $js = "jQuery('#{$this->id}').fancybox($options);";
            $view->registerJs($js , View::POS_READY);
        }
    }
881927
public function findAllWidgetsForView(View $view)
    {
        $qb = $this->getAllForView($view);

        return $qb->getQuery()->getResult();
    }