Inject parameters into $parameters if available in the $view and supported by the QueryType.

@param array $parameters
@param string $queryTypeName
@param \Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView $view
511208
private function injectSupportedParameters(array &$parameters, $queryTypeName, ContentView $view)
    {
        $queryType = $this->queryTypeRegistry->getQueryType($queryTypeName);

        if (!$queryType instanceof SiteQueryType) {
            return;
        }

        if (!array_key_exists('content', $parameters) && $queryType->supportsParameter('content')) {
            $parameters['content'] = $view->getSiteContent();
        }

        if (!array_key_exists('location', $parameters) && $queryType->supportsParameter('location')) {
            $parameters['location'] = $view->getSiteLocation();
        }
    }
411054
public function render(Content $content, $parameters)
    {
        if(!array_key_exists($content->getType(), $this->filters))
        {
            throw new RenderException(
                'Content filter [' . $content->getType() . '] not found. Available filters: ' .
                implode(', ', array_keys($this->filters)) . '.'
            );
        }

        $renderedContent = $this->filters[$content->getType()]->render($content, $parameters);

        if(preg_match_all('/\{\{\s*(include)\s+([a-z0-9\_\-\.\/]+)\s*\}\}/i', $renderedContent, $matches))
        {
            $matchesCount = count($matches[0]);
            for($i = 0; $i < $matchesCount; $i++)
            {
                $includedContent = $this->renderIncludeForContent($content, $matches[2][$i], $parameters);
                $renderedContent = str_replace($matches[0][$i], $includedContent, $renderedContent);
            }
        }

        return $renderedContent;
    }
589213
function setActionParameter( $parameterName, $parameterValue, $view = '' )
    {
        if ( $view == '' )
            $view = self::currentView();
        $this->ViewActionParameters[$view][$parameterName] = $parameterValue;
    }
133323
public function addDefaultQueryParameters($queryParameters)
    {
        foreach ($queryParameters as $name => $value) {
            $this->addDefaultQueryParameter($name, $value);
        }

        return $this;
    }
1230995
public function showFolderListAsideViewAction(ContentView $view)
    {
        $subContentCriteria = $this->get('ezdemo.criteria_helper')->generateSubContentCriterion(
            $view->getLocation(),
            $this->container->getParameter('ezdemo.folder.folder_tree.included_content_types'),
            $this->getConfigResolver()->getParameter('languages')
        );

        $subContentQuery = new LocationQuery();
        $subContentQuery->query = $subContentCriteria;
        $subContentQuery->sortClauses = array(
            new SortClause\ContentName(),
        );
        $subContentQuery->performCount = false;

        $searchService = $this->getRepository()->getSearchService();
        $subContent = $searchService->findLocations($subContentQuery);

        $treeChildItems = array();
        foreach ($subContent->searchHits as $hit) {
            $treeChildItems[] = $hit->valueObject;
        }

        $view->addParameters(['treeChildItems' => $treeChildItems]);

        return $view;
    }
699863
public function addQueryParameters($queryString)
    {
        $queries = preg_split('/&(amp;)?/i', $queryString);

        foreach ($queries as $v) {
            $explode = explode('=', $v);

            $name  = $explode[0];
            $value = isset($explode[1]) ? $explode[1] : '';
            $rpos  = strrpos($name, '?');

            if ($rpos !== false) {
                $name = substr($name, ($rpos + 1));
            }

            if (empty($name)) {
                continue;
            }

            $this->setQueryParameter($name, $value);
        }

        return $this;
    }
416868
protected function renderContent(Content $content, $viewType, $layout = false, array $params = array())
    {
        return $this->viewManager->renderContent($content, $viewType, $params + array('noLayout' => !$layout));
    }
1046993
public static function pq($html, $contentType = null)
    {
        self::initPhpQuery();
        return \phpQuery::newDocument($html, $contentType);
    }
185348
public function addRequestAttributes(FilterViewBuilderParametersEvent $e)
    {
        $parameterBag = $e->getParameters();
        $parameterBag->add($e->getRequest()->attributes->all());

        // maybe this should be in its own listener ? The ViewBuilder needs it.
        if (!$parameterBag->has('viewType')) {
            $parameterBag->add(['viewType' => null]);
        }
    }
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);
                }
            }
        }
    }
171231
public function addToContentType($fieldName, ContentType $contentType)
    {
        try {
            $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentType->id);
        } catch (NotFoundException $e) {
            $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType);
        }

        $typeUpdate = $this->contentTypeService->newContentTypeUpdateStruct();
        $typeUpdate->modificationDate = new DateTime();

        $knowLanguage = array_keys($contentType->getDescriptions());

        if (!in_array($contentType->mainLanguageCode, $knowLanguage)) {
            $knowLanguage[] = $contentType->mainLanguageCode;
        }

        $fieldCreateStruct = $this->contentTypeService->newFieldDefinitionCreateStruct(
            $fieldName,
            'novaseometas'
        );

        $fieldCreateStruct->names = array_fill_keys($knowLanguage, $this->metaFieldName);
        $fieldCreateStruct->descriptions = array_fill_keys($knowLanguage, $this->metaFieldDescription);
        $fieldCreateStruct->fieldGroup = $this->metaFieldGroup;
        $fieldCreateStruct->position = 100;
        $fieldCreateStruct->isTranslatable = true;
        $fieldCreateStruct->isRequired = false;
        $fieldCreateStruct->isSearchable = false;
        $fieldCreateStruct->isInfoCollector = false;

        try {
            $this->contentTypeService->updateContentTypeDraft($contentTypeDraft, $typeUpdate);

            if ($contentTypeDraft->getFieldDefinition($fieldName) == null) {
                $this->contentTypeService->addFieldDefinition($contentTypeDraft, $fieldCreateStruct);
            }

            $this->contentTypeService->publishContentTypeDraft($contentTypeDraft);

            return true;
        } catch (Exception $e) {
            $this->errorMessage = $e->getMessage();

            return false;
        }
    }
973181
protected function prepareContentByContentTypeIds($contentTypeIds, Request $request)
    {
        $options = $this->parseParameters($request->query, ['page_size', 'page', 'path', 'hidden', 'lang', 'sa', 'image']);

        $pageSize = (int)$options->get('page_size', self::PAGE_SIZE);
        $page = (int)$options->get('page', 1);
        $offset = $page * $pageSize - $pageSize;
        $path = $options->get('path');
        $hidden = $options->get('hidden');
        $lang = $options->get('lang');
        $siteAccess = $options->get('sa');

        $rootLocationPathString = $this->locationService->loadLocation(
            $this->siteAccessHelper->getRootLocationBySiteAccessName($siteAccess)
        )->pathString;

        $contentItems = array();

        foreach ($contentTypeIds as $contentTypeId) {
            $criteria = array(new Criterion\ContentTypeId($contentTypeId));

            if ($path) {
                $criteria[] = new Criterion\Subtree($path);
            }

            if (!$hidden) {
                $criteria[] = new Criterion\Visibility(Criterion\Visibility::VISIBLE);
            }

            $criteria[] = new Criterion\Subtree($rootLocationPathString);

            $query = new Query();
            $query->query = new Criterion\LogicalAnd($criteria);
            $query->limit = $pageSize;
            $query->offset = $offset;

            $contentItems[$contentTypeId] = $this->searchService->findContent(
                $query,
                (!empty($lang) ? array('languages' => array($lang)) : array())
            )->searchHits;
        }

        $contentOptions = $this->parseParameters($request->query, ['lang', 'fields', 'image']);

        return $this->content->prepareContent($contentItems, $contentOptions);
    }
1350950
public function addView(View $view)
    {
        if ($this->hasView($view->getName())) {
            throw SchemaException::schemaViewAlreadyExists($this->getName(), $view->getName());
        }

        $this->views[$view->getName()] = $view;
    }
1336408
private function supplyContentType(ContentView $view): void
    {
        $contentType = $this->contentTypeService->loadContentType(
            $view->getContent()->contentInfo->contentTypeId,
            $this->userLanguagePreferenceProvider->getPreferredLanguages()
        );
        $view->addParameters(['contentType' => $contentType]);
    }
683118
private function buildQueryDefinition(array $configuration, ContentView $view)
    {
        $parameters = $this->processParameters($configuration['parameters'], $view);

        $this->injectSupportedParameters($parameters, $configuration['query_type'], $view);

        return new QueryDefinition([
            'name' => $configuration['query_type'],
            'parameters' => $parameters,
            'useFilter' => $this->parameterProcessor->process($configuration['use_filter'], $view),
            'maxPerPage' => $this->parameterProcessor->process($configuration['max_per_page'], $view),
            'page' => $this->parameterProcessor->process($configuration['page'], $view),
        ]);
    }
385179
public function showFolderListAction(Request $request, ContentView $view)
    {
        $languages = $this->getConfigResolver()->getParameter('languages');

        // Using the criteria helper (a demobundle custom service) to generate our query's criteria.
        // This is a good practice in order to have less code in your controller.
        $criteria = $this->get('ezdemo.criteria_helper')->generateListFolderCriterion(
            $view->getLocation(),
            $this->container->getParameter('ezdemo.folder.folder_view.excluded_content_types'),
            $languages
        );

        // Generating query
        $query = new LocationQuery();
        $query->query = $criteria;
        $query->sortClauses = array(
            new SortClause\DatePublished(),
        );

        // Initialize pagination.
        $pager = new Pagerfanta(
            new ContentSearchAdapter($query, $this->getRepository()->getSearchService())
        );

        $pager->setMaxPerPage($this->container->getParameter('ezdemo.folder.folder_list.limit'));
        $pager->setCurrentPage($request->get('page', 1));

        $includedContentTypeIdentifiers = $this->container->getParameter('ezdemo.folder.folder_tree.included_content_types');

        // Get sub folder structure
        $subContentCriteria = $this->get('ezdemo.criteria_helper')->generateSubContentCriterion(
            $view->getLocation(), $includedContentTypeIdentifiers, $languages
        );

        $subContentQuery = new LocationQuery();
        $subContentQuery->query = $subContentCriteria;
        $subContentQuery->sortClauses = array(
            new SortClause\ContentName(),
        );

        $searchService = $this->getRepository()->getSearchService();
        $subContent = $searchService->findLocations($subContentQuery);

        $treeItems = array();
        foreach ($subContent->searchHits as $hit) {
            $treeItems[] = $hit->valueObject;
        }

        $view->addParameters(['pagerFolder' => $pager, 'treeItems' => $treeItems]);

        return $view;
    }
310036
private function runQuery(ContentView $view, $method)
    {
        $searchResults = $this->searchService->$method(
            $this->contentViewQueryTypeMapper->map($view)
        );
        $view->addParameters([$view->getParameter('query')['assign_results_to'] => $searchResults]);
    }