Compute weigthed rewrites for the query.

@param ContainerConfigurationInterface $containerConfig Search request container config.
@param string                          $queryText       Fulltext query.

@return array
506971
private function computeQueryRewrites(ContainerConfigurationInterface $containerConfig, $queryText)
    {
        $config   = $this->getConfig($containerConfig);
        $storeId  = $containerConfig->getStoreId();
        $rewrites = [];
        $maxRewrites = $config->getMaxRewrites();

        if ($config->isSynonymSearchEnabled()) {
            $thesaurusType   = ThesaurusInterface::TYPE_SYNONYM;
            $synonymRewrites = $this->getSynonymRewrites($storeId, $queryText, $thesaurusType, $maxRewrites);
            $rewrites        = $this->getWeightedRewrites($synonymRewrites, $config->getSynonymWeightDivider());
        }

        if ($config->isExpansionSearchEnabled()) {
            $synonymRewrites = array_merge([$queryText => 1], $rewrites);

            foreach ($synonymRewrites as $currentQueryText => $currentWeight) {
                $thesaurusType     = ThesaurusInterface::TYPE_EXPANSION;
                $expansions        = $this->getSynonymRewrites($storeId, $currentQueryText, $thesaurusType, $maxRewrites);
                $expansionRewrites = $this->getWeightedRewrites($expansions, $config->getExpansionWeightDivider(), $currentWeight);
                $rewrites          = array_merge($rewrites, $expansionRewrites);
            }
        }

        return $rewrites;
    }
526049
private function createResolver(array $config, ContainerInterface $container)
    {
        $resolvers = [];
        if (isset($config['resolvers'])) {
            $resolvers = $this->createResolvers($config['resolvers'], $container);
        }

        $aggregate = new Resolver\AggregateResolver();
        foreach ($resolvers as $resolver) {
            $aggregate->attach($resolver);
        }

        if ($aggregate->hasType(Resolver\DefaultResolver::class)) {
            $defaultResolver = $aggregate->fetchByType(Resolver\DefaultResolver::class);
        } else {
            $defaultResolver = new Resolver\DefaultResolver();
            $aggregate->attach($defaultResolver, 0);
        }

        if (isset($config['paths']) && is_array($config['paths'])) {
            $this->injectResolverPaths($config['paths'], $defaultResolver);
        }

        if (isset($config['suffix']) && is_string($config['suffix']) && ! empty($config['suffix'])) {
            $defaultResolver->setSuffix($config['suffix']);
        }

        if (isset($config['separator']) && is_string($config['separator']) && ! empty($config['separator'])) {
            $defaultResolver->setSeparator($config['separator']);
        }

        return $aggregate;
    }
1073668
protected function getTemplatesSettings(ContainerInterface $container): array
    {
        $tplConfig = $container->get(SettingsProviderInterface::class)->get(TemplatesSettings::class);

        return $tplConfig;
    }
526255
protected function loadConfigurationRecursive(ContainerBuilder $container, array $configuration)
    {
        foreach ($configuration as $values) {
            $loader = new XmlFileLoader($container, new FileLocator($values['path']));
            foreach ($values['configFiles'] as $configFile) {
                $loader->load($configFile);
            }
            if (array_key_exists('configuration', $values)) {
                $this->loadConfigurationRecursive($container, $values['configuration']);
            }
        }
    }
691993
private function validateCustomStylesConfiguration(
        ContainerInterface $container,
        array $enabledCustomStyles
    ) {
        $definedCustomStyles = array_keys(
            $container->getParameter(EzPublishCoreExtension::RICHTEXT_CUSTOM_STYLES_PARAMETER)
        );
        foreach ($enabledCustomStyles as $customStyleName) {
            if (!in_array($customStyleName, $definedCustomStyles)) {
                throw new InvalidConfigurationException(
                    "Unknown RichText Custom Style '{$customStyleName}'"
                );
            }
        }
    }
309864
public function load(ContainerBuilder $container, array $config)
    {
        if (isset($config['connection_details'])) {
            DEFINE('SQLDBENGINE', $config['connection_details']['engine']);
            DEFINE('SQLDBHOST', $config['connection_details']['host']);
            DEFINE('SQLDBSCHEMA', $config['connection_details']['schema']);
            DEFINE('SQLDBNAME', $config['connection_details']['dbname']);
            DEFINE('SQLDBUSERNAME', $config['connection_details']['username']);
            DEFINE('SQLDBPASSWORD', $config['connection_details']['password']);
            DEFINE('SQLDBPREFIX', $config['connection_details']['dbprefix']);
            session_start();
            // Store any keywords set in behat.yml file
            if (isset($config['keywords']) and $config['keywords']) {
                foreach ($config['keywords'] as $keyword => $value) {
                    $_SESSION['behat']['GenesisSqlExtension']['keywords'][$keyword] = $value;
                }
            }

            // Set 'notQuotableKeywords' for later use.
            $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords'] = [];

            if (isset($config['notQuotableKeywords'])) {
                $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords'] = $config['notQuotableKeywords'];
            }
        }
    }
979118
private function getFileCacheDir(array $cacheConfig, ContainerBuilder $container)
    {
        $dir = sprintf('%s/as3_modlr', $container->getParameter('kernel.cache_dir'));
        if (isset($cacheConfig['parameters']['dir'])) {
            $dir = $cacheConfig['parameters']['dir'];
        }
        return $dir;
    }
1082518
private function loadMaxRedirects(array $config, ContainerBuilder $container)
    {
        $services = array('buzz', 'curl', 'guzzle', 'stream', 'zend');

        foreach ($services as $service) {
            $container
                ->getDefinition(sprintf('widop_http_adapter.%s', $service))
                ->addMethodCall('setMaxRedirects', array($config['max_redirects']));
        }
    }
998454
private function getOptimizersFunctions(ContainerConfigurationInterface $containerConfiguration, $optimizers)
    {
        $functions = [];

        foreach ($optimizers as $optimizer) {
            $function = $this->getFunction($containerConfiguration, $optimizer);

            if ($function !== null) {
                $functions[$optimizer->getId()] = $function;
            }
        }

        return $functions;
    }
589272
public function transform(ConfigurationInterface $config)
    {
        return [
            self::EMAIL_SENDER         => $config->getEmailSender(),
            self::EMAIL_SENDER_NAME    => $config->getEmailSenderName(),
            self::EMAIL_SUBJECT_PREFIX => $config->getEmailSubjectPrefix(),
            self::EMAIL_BODY_SIGNATURE => $config->getEmailBodySignature()
        ];
    }
144864
protected function configureTwigBundle(ContainerBuilder $container, array $config)
    {
        if ($container->hasExtension('twig')) {
            $resources = array('LifoTypeaheadBundle:Form:typeahead.html.twig');
            if (Kernel::VERSION_ID >= '20600') {
                $container->prependExtensionConfig('twig', array('form_themes' => $resources));
            } else {
                $container->prependExtensionConfig('twig', array('form' => array('resources' => $resources)));
            }
        }
    }
504908
private function loadParameters(ContainerBuilder $container, array $config)
    {
        // Store config in parameters array to be passed into the DrupalContext.
        $drupal_parameters = array();
        foreach ($config as $key => $value) {
            $drupal_parameters[$key] = $value;
        }
        $container->setParameter('drupal.parameters', $drupal_parameters);

        $container->setParameter('drupal.region_map', $config['region_map']);
    }
890513
public function loadContextInstancesByContainer(ContainerInterface $container)
    {

        // initialize the array for the context instances
        $contextInstances = array();

        // iterate over all applications and create the context configuration
        foreach (glob($container->getAppBase() . '/*', GLOB_ONLYDIR) as $webappPath) {
            $context = $this->loadContextInstance($container->getContainerNode(), $webappPath);
            $contextInstances[$context->getName()] = $context;
        }

        // return the array with the context instances
        return $contextInstances;
    }
1144613
private function getPhoneticQuery(ContainerConfigurationInterface $containerConfig, $queryText)
    {
        $relevanceConfig    = $containerConfig->getRelevanceConfig();
        $analyzer           = FieldInterface::ANALYZER_PHONETIC;
        $defaultSearchField = MappingInterface::DEFAULT_SPELLING_FIELD;
        $fuzzyFieldFilter   = $this->fieldFilters['fuzzyFieldFilter'];

        $searchFields = $this->getWeightedFields($containerConfig, $analyzer, $fuzzyFieldFilter, $defaultSearchField);

        $queryParams = [
            'fields'             => $searchFields,
            'queryText'          => $queryText,
            'minimumShouldMatch' => "100%",
            'tieBreaker'         => $relevanceConfig->getTieBreaker(),
            'cutoffFrequency'    => $relevanceConfig->getCutoffFrequency(),
        ];

        return $this->queryFactory->create(QueryInterface::TYPE_MULTIMATCH, $queryParams);
    }
1248911
private function validateCustomTagsConfiguration(
        ContainerInterface $container,
        array $enabledCustomTags
    ) {
        $definedCustomTags = array_keys(
            $container->getParameter(EzPublishCoreExtension::RICHTEXT_CUSTOM_TAGS_PARAMETER)
        );
        foreach ($enabledCustomTags as $customTagName) {
            if (!in_array($customTagName, $definedCustomTags)) {
                throw new InvalidConfigurationException(
                    "Unknown RichText Custom Tag '{$customTagName}'"
                );
            }
        }
    }
145641
private static function createConfiguration(array $config, ContainerInterface $container = null)
    {
        $cache = $config['cache'];

        if ($container && is_string($config['cache']) && $container->has($config['cache'])) {
            $cache = $container->get($config['cache']);
        }

        return Setup::createConfiguration($config['debug'], $config['proxy_dir'], $cache);
    }
254763
private function getResultList(ConfigurationInterface $moduleConfiguration)
    {
        $state = $this->stateFactory->createState();
        $enrichState = $this->stateFactory->createStateEnrichedWithDefaults($state, $moduleConfiguration);
        $result = $this->resultFactory->createResult($moduleConfiguration, $enrichState);
        $resultArray = $result->asArray();
        $iterator = new \TIterator();
        foreach ($resultArray as $article) {
            $iterator->AddItem($article);
        }

        return $iterator;
    }