@param Widget $widget
@param View   $view
@param string $businessEntityId
@param string $namespace
@param int    $position
@param string $slot

@return array
768158
protected function buildEntityForms($widget, View $view, $businessEntityId = null, $namespace = null, $position = null, $parentWidgetMap = null, $slot = null, $quantum = null)
    {
        $forms = [];

        //get the entity form
        $entityForm = $this->buildForm($widget, $view, $businessEntityId, $namespace, Widget::MODE_ENTITY, $slot, $position, $parentWidgetMap, $quantum);
        $forms[Widget::MODE_ENTITY] = $entityForm;

        //get the query form
        $queryForm = $this->buildForm($widget, $view, $businessEntityId, $namespace, Widget::MODE_QUERY, $slot, $position, $parentWidgetMap, $quantum);
        $forms[Widget::MODE_QUERY] = $queryForm;

        //get the query form
        $businessEntityForm = $this->buildForm($widget, $view, $businessEntityId, $namespace, Widget::MODE_BUSINESS_ENTITY, $slot, $position, $parentWidgetMap, $quantum);
        $forms[Widget::MODE_BUSINESS_ENTITY] = $businessEntityForm;

        return $forms;
    }
1105416
protected static function view(
        ContainerInterface $container,
        int $viewId,
        array $parameters = [],
        string $viewsNamespace = Views::NAMESPACE
    ): string {
        $formatter    = static::createFormatter($container, $viewsNamespace);
        $templateName = $formatter->formatMessage($viewId);

        /** @var TemplatesInterface $templates */
        $templates = $container->get(TemplatesInterface::class);

        /** @var CacheSettingsProviderInterface $provider */
        $provider  = $container->get(CacheSettingsProviderInterface::class);
        $originUri = $provider->getApplicationConfiguration()[A::KEY_APP_ORIGIN_URI];

        $currentUser = static::getCurrentUser($container);

        $curHostName = static::getHostUri($container);

        $isSignedIn = $currentUser !== null;
        if ($isSignedIn === true) {
            $firstName = $currentUser->getProperty(User::FIELD_FIRST_NAME);
            $lastName  = $currentUser->getProperty(User::FIELD_LAST_NAME);
            $roleName  = $currentUser->getProperty(Role::FIELD_ID);

            $allowedScopes  = $currentUser->getScopes();
            $canAdminUsers  = in_array(PassportSeed::SCOPE_ADMIN_USERS, $allowedScopes);
            $canAdminRoles  = in_array(PassportSeed::SCOPE_ADMIN_ROLES, $allowedScopes);
            $canViewUsers   = in_array(PassportSeed::SCOPE_VIEW_USERS, $allowedScopes);
            $canViewRoles   = in_array(PassportSeed::SCOPE_VIEW_ROLES, $allowedScopes);
            $indexMethod    = WebControllerInterface::METHOD_INDEX;
            $usersRouteName = static::routeName(WebRoutes::TOP_GROUP_PREFIX, UserSchema::TYPE, $indexMethod);
            $rolesRouteName = static::routeName(WebRoutes::TOP_GROUP_PREFIX, RoleSchema::TYPE, $indexMethod);
            $usersUrl       = $canViewUsers === true ? static::createRouteUrl($container, $usersRouteName) : null;
            $rolesUrl       = $canViewRoles === true ? static::createRouteUrl($container, $rolesRouteName) : null;

            $signInUrl  = null;
            $signOutUrl = static::createRouteUrl($container, AuthController::ROUTE_NAME_LOGOUT);
        } else {
            $firstName     = null;
            $lastName      = null;
            $roleName      = null;
            $canAdminUsers = false;
            $canAdminRoles = false;
            $canViewUsers  = false;
            $canViewRoles  = false;
            $usersUrl      = null;
            $rolesUrl      = null;
            $signInUrl     = static::createRouteUrl($container, AuthController::ROUTE_NAME_SIGN_IN);
            $signOutUrl    = null;
        }

        $defaultParams = [
            '_origin_uri' => $originUri,
            'host_name'   => $curHostName,

            'is_signed_in' => $isSignedIn,
            'sign_in_url'  => $signInUrl,
            'sign_out_url' => $signOutUrl,

            'first_name'      => $firstName,
            'last_name'       => $lastName,
            'role_name'       => $roleName,
            'can_admin_users' => $canAdminUsers,
            'can_admin_roles' => $canAdminRoles,
            'can_view_users'  => $canViewUsers,
            'can_view_roles'  => $canViewRoles,
            'users_url'       => $usersUrl,
            'roles_url'       => $rolesUrl,
        ];

        $body = $templates->render($templateName, $parameters + $defaultParams);

        return $body;
    }
705787
public function generateViewCss(View $view, array $widgets)
    {
        $css = '';

        foreach ($widgets as $widget) {
            $style = $this->container->get('templating')->render(
            'VictoireCoreBundle:Widget:style/style.html.twig',
            [
                'widget'                   => $widget,
                'victoire_twig_responsive' => $this->victoireTwigResponsive,
            ]
        );
            $css .= trim($style);
        }

        if ($css !== '') {
            $this->writeCssFile($view, $css);
        }
    }
158587
public function transform($widget)
    {
        $widget = $this->entityToArray(Widget::class, $widget);
        return [
            'id'          => (int) $widget['id'],
            'name'        => $widget['name'],
            'args'        => array_camel_case_keys($widget['args']),
            'isActive'    => (bool) $widget['is_active'],
            'isCacheable' => (bool) $widget['is_cacheable'],
            'createdAt'   => $widget['created_at'],
            'updatedAt'   => $widget['updated_at'],
        ];
    }
1267955
function(starting_widget, guid) {

		if (Lava.schema.DEBUG && !guid) Lava.t();

		return this._views_by_guid[guid];

	}
853244
public function create(Widget $widget)
    {
        $widget->extension_id = old('extension_id', Extension::WIDGET_WYSIWYG);
        $widget->template     = old('template', 'widgets.wysiwyg.raw');
        $widget->published    = old('published', true);

        return view('administrator.widgets.create', compact('widget'));
    }
467734
public function index(WidgetContractInterface $widget, $key = null)
    {
        $widget->query = request('term');
        $widget->key = $key;

        if (! is_null($key)) {
            return response()->json($widget->handler());
        }

        return response()->json([
            'results' => $widget->handler(),
        ]);
    }
455079
public function buildWidgetStyleForm(Widget $widget, $viewReference, $quantum)
    {
        $formFactory = $this->container->get('form.factory');

        $options = [
            'method' => 'POST',
            'action' => $this->container->get('router')->generate(
                'victoire_core_widget_stylize',
                [
                    'id'            => $widget->getId(),
                    'viewReference' => $viewReference,
                    'quantum'       => $quantum,
                ]
            ),
        ];

        $mockForm = $formFactory->create(WidgetStyleType::class, $widget, $options);
        $builder = $formFactory->createNamed(
            sprintf('%s_%s', $quantum, $mockForm->getName()),
            WidgetStyleType::class,
            $widget,
            $options
        );

        return $builder;
    }
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);
    }
570275
public function renderNewQuantumForms($slot, View $view, $widgets, Widget $activeWidget, $classes, $position = null, $parentWidgetMap = null, $quantum = null)
    {
        $forms = [];
        foreach ($widgets as $key => $widget) {
            $_quantum = null !== $quantum ? $quantum : $this->convertToString($key);
            $forms[$key] = $this->renderNewWidgetForms($slot, $view, $widget, $classes, $position, $parentWidgetMap, $_quantum);
            $forms[$key]['quantum'] = $_quantum;
            $forms[$key]['active'] = $widget === $activeWidget ? true : false;
        }

        return $forms;
    }
1300226
public function isWidgetAllowedForSlot(Widget $widget, $slot)
    {
        $widgetName = $this->getWidgetName($widget);
        $slots = $this->slots;

        return !empty($slots[$slot]) && (array_key_exists($widgetName, $slots[$slot]['widgets']));
    }
11502
public function getChildren(WidgetMap $widgetMap, View $view = null)
    {
        $positions = [WidgetMap::POSITION_BEFORE, WidgetMap::POSITION_AFTER];
        $children = [];
        foreach ($positions as $position) {
            $matchingChildren = [];

            //Position is null by default
            $children[$position] = null;

            //Pass through all current WidgetMap children for a given position
            foreach ($widgetMap->getContextualChildren($position) as $_child) {
                //If child don't have a substitute for this View and Templates, this is the one
                if (null === $_child->getSubstituteForView($view)) {
                    $children[$position] = $_child;
                    $matchingChildren[] = $_child->getId();
                }
            }

            //If children has not been found for this position
            //and current WidgetMap is a substitute
            if (!$children[$position] && $widgetMap->getReplaced()) {
                //Pass through all replaced WidgetMap children for a given position
                foreach ($widgetMap->getReplaced()->getContextualChildren($position) as $_child) {
                    //If child don't have a substitute for this View and Templates, this is the one
                    if (null === $_child->getSubstituteForView($view)) {
                        $children[$position] = $_child;
                        $matchingChildren[] = $_child->getId();
                    }
                }
            }

            $matchingChildren = array_unique($matchingChildren);
            if (count($matchingChildren) > 1) {
                $this->logger->critical(sprintf(
                    'Conflict found between WidgetMaps %s for View %s',
                    implode(', ', $matchingChildren),
                    $view->getId()
                ));
            }
        }

        return $children;
    }
1330693
protected function makeReportWidget($alias, $widgetInfo)
    {
        $configuration = $widgetInfo['configuration'];
        $configuration['alias'] = $alias;

        $className = $widgetInfo['class'];
        if (!class_exists($className)) {
            return;
        }

        $widget = new $className($this->controller, $configuration);
        $widget->bindToController();

        return ['widget' => $widget, 'sortOrder' => $widgetInfo['sortOrder']];
    }
1000661
public function getView(AbstractWidget $widget, $widgetType)
    {
        $widgetViewEvent = new WidgetViewEvent($widgetType, $widget);

        $this->eventDispatcher->dispatch('icap_portfolio_widget_view_'.$widgetType, $widgetViewEvent);

        return $widgetViewEvent->getView();
    }
1115011
public function parameters($id, $widget)
    {
        $widget    = Widget::withoutGlobalScope('menu_assignment')->findOrNew($widget);
        $extension = $this->repository->findOrFail($id);
        $formView  = $extension->param('form');

        if (view()->exists($formView)) {
            return view($formView, compact('widget'));
        }

        return view('widgets.partials.none');
    }
997537
private function getWidgetContent(WidgetInterface $widget)
    {
        if (!isset($this->widgetContents[$widget->getName()])) {
            try {
                $this->widgetContents[$widget->getName()] = $widget->getContent();
            } catch (KernelHttpException $ex) {
                throw new HttpException($ex);
            }
        }

        return $this->widgetContents[$widget->getName()];
    }
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);
    }