Append an analyzer for a thesaurus to existing settings.

@param array    $settings Original settings.
@param string   $type     Thesaurus type.
@param string[] $values   Thesaurus entries in Lucene format.

@return array
548022
private function addAnalyzerSettings($settings, $type, $values)
    {
        $settings['analysis']['analyzer'][$type] = [
            'tokenizer' => 'whitespace',
            'filter' => ['lowercase', 'shingle'],
        ];

        if (!empty($values)) {
            $values = $this->prepareSynonymFilterData($values);
            $settings['analysis']['filter'][$type] = ['type' => 'synonym', 'synonyms' => $values];
            $settings['analysis']['analyzer'][$type]['filter'][] = $type;
        }

        $settings['analysis']['analyzer'][$type]['filter'][] = 'type_filter';

        return $settings;
    }
1080718
public static function getIdValues(array $mappings, array $value, $type)
    {
        $ids = [];
        foreach (\array_keys($value) as $propertyName) {
            if (\in_array($propertyName, RecursiveFormatterHelper::getIdProperties($mappings, $type), true)) {
                $id = RecursiveFormatterHelper::getIdValue($value[$propertyName]);
                $ids[] = (\is_array($id)) ? \implode(JsonApiTransformer::ID_SEPARATOR, $id) : $id;
            }
        }

        return $ids;
    }
478278
private function applyOrders(array $settings): array
    {
        $orders = [];
        // Obtain a list of columns
        foreach ($settings as $column => $order) {
            $column = Proxy\Db::quoteIdentifier($column);
            $orders[] = $column . ' ' . $order;
        }
        return $orders;
    }
119369
public function mapParameters(ParameterDefinitionCollectionInterface $definitions, array $values): Generator
    {
        foreach ($definitions->getParameterDefinitions() as $parameterDefinition) {
            $parameterName = $parameterDefinition->getName();
            $parameterType = $parameterDefinition->getType();

            $value = array_key_exists($parameterName, $values) ?
                $parameterType->fromHash($parameterDefinition, $values[$parameterName]) :
                $parameterDefinition->getDefaultValue();

            yield $parameterName => Parameter::fromArray(
                [
                    'name' => $parameterName,
                    'parameterDefinition' => $parameterDefinition,
                    'value' => $value,
                    'isEmpty' => $parameterType->isValueEmpty($parameterDefinition, $value),
                ]
            );

            if ($parameterDefinition instanceof CompoundParameterDefinition) {
                yield from $this->mapParameters($parameterDefinition, $values);
            }
        }
    }
352810
protected function addModelSettings(array &$settings)
    {
        $empty = $this->util->getTranslated()->getEmptyDropdownArray();

        $settings['elementClass'] = 'Select';
        $settings['multiOptions'] = $empty + $this->util->getDbLookup()->getUserConsents();
    }
407002
public function checkSettings($settings)
    {
        assert('is_array($settings)');

        if (!is_array($settings) || empty($settings)) {
            $errors = array('invalid_syntax');
        } else {
            $errors = array();
            if (!$this->_spValidationOnly) {
                $idpErrors = $this->checkIdPSettings($settings);
                $errors = array_merge($idpErrors, $errors);
            }
            $spErrors = $this->checkSPSettings($settings);
            $errors = array_merge($spErrors, $errors);

            $compressErrors = $this->checkCompressionSettings($settings);
            $errors = array_merge($compressErrors, $errors);
        }

        return $errors;
    }
680473
public static function getRoutesFromSettings(array $settings): array{
        $routes = [];
        foreach ($settings['routing'] as $method => $urls) {
            if (!isset($routes[$method])) {
                $routes[$method] = [];
            }
            foreach ($urls as $url) {
                array_push($routes[$method], (array)$url);
            }
        }
        return $routes;
    }
1105111
public function whereTypeIn(array $types)
    {
        if (count($types) > 0) {
            $this->joinSingleRelatives = true;
            $clause = '';

            for ($i = 0, $count = count($types); $i < $count; $i++) {
                $clause .= $i === 0 ?
                    "resourceType.name = :type_{$i}" :
                    "OR resourceType.name = :type_{$i}";
                $clause .= $i < $count - 1 ? PHP_EOL : '';
                $this->parameters[":type_{$i}"] = $types[$i];
            }

            $this->addWhereClause($clause);
        }

        return $this;
    }
1139110
public function addSettings(array $settings)
    {
        foreach ($settings as $key => $value) {
            $this->addSetting($key, $value);
        }
    }
1332716
public function findDefaults(array &$settings)
    {
        if (!isset($settings['allow_multiple_selection'])) {
            $settings['allow_multiple_selection'] = 'no';
        }

        if (!isset($settings['show_association'])) {
            $settings['show_association'] = 'no';
        }

        if (!isset($settings['sort_options'])) {
            $settings['sort_options'] = 'no';
        }
    }
886048
private function bindUntypedValues(array $values)
    {
        $params = [];
        $types  = str_repeat('s', count($values));

        foreach ($values as &$v) {
            $params[] =& $v;
        }

        return $this->_stmt->bind_param($types, ...$params);
    }
347993
protected function removeDots(array $settings): array
    {
        $conf = [];
        foreach ($settings as $key => $value) {
            $conf[$this->removeDotAtTheEnd($key)] = \is_array($value) ? $this->removeDots($value) : $value;
        }
        return $conf;
    }
773309
public function settings(array $settings = null)
    {
        if ($settings !== null) {
            $this->settings = $settings;
        }

        return $this->settings;
    }
330057
public function injectSettings(array $settings)
    {
        $this->rejectAll = $settings['security']['firewall']['rejectAll'];
        $this->filters = array_map([$this, 'createFilterFromConfiguration'], array_values($settings['security']['firewall']['filters']));
    }
85845
private function formatParameters(array $parameters, string $type): array
    {
        $this->checkQueryRepositoryCompatibility($type);
        $this->checkQueryResourceId($parameters, $type);

        $returnParameters = [];

        foreach ($parameters['query'] as $parameter => $value) {
            // The parameter is a filter,
            // so it must be checked if it is whitelisted
            if ('filter_by' === $parameter) {
                $returnParameters['filter'] = $this->queryAddFilterByParameter($value);

                continue;
            }

            // The parameter is a sorting field,
            // so it must be checked if it is whitelisted
            if ('sort_by' === $parameter) {
                $returnParameters['sort'] = $this->queryAddSortByParameter($value);

                continue;
            }

            // The parameter is a list of fields,
            // so it must be checked whether they are supported by the Repository
            if ('field_list' === $parameter) {
                $returnParameters['field_list'] = $this->queryAddFieldList($type, $value);

                continue;
            }

            // The parameter is of any other kind,
            // so it must be checked that it is supported by the Repository
            if (!\in_array($parameter, $this->queryParameters, true)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Parameter %s is not a valid query parameters for repository %s',
                    $parameter,
                    $this->name
                ));
            }
            if (!\is_string($value) && !\is_numeric($value)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Value for parameter %s is not a valid type, must be either a string or a number, %s given',
                    $parameter,
                    \gettype($value)
                ));
            }
            $returnParameters[$parameter] = $value;
        }

        return [
            'parameters' => $returnParameters,
            'resource_id' => $parameters['resource_id'],
        ];
    }
748793
public function mergeSettings(array $savedSettings, array $definedSettings)
    {
        // Test if the saved settings are for site or page. Only site settings have the category key
        $pageSetting = isset($savedSettings[0]->category) ? false : true;

        // Make index of saved setting keys to setting array for easy lookup
        $settingIndex = array_combine(array_column($savedSettings, 'setting_key'), array_keys($savedSettings));

        // Loop through defined settings and update with saved values and meta info
        foreach ($definedSettings as $defKey => $setting) {
            if (isset($settingIndex[$setting->key])) {
                $definedSettings[$defKey]->id = $savedSettings[$settingIndex[$setting->key]]->id;
                $definedSettings[$defKey]->setting_value = $savedSettings[$settingIndex[$setting->key]]->setting_value;
                $definedSettings[$defKey]->created_by = $savedSettings[$settingIndex[$setting->key]]->created_by;
                $definedSettings[$defKey]->created_date = $savedSettings[$settingIndex[$setting->key]]->created_date;
                $definedSettings[$defKey]->updated_by = $savedSettings[$settingIndex[$setting->key]]->updated_by;
                $definedSettings[$defKey]->updated_date = $savedSettings[$settingIndex[$setting->key]]->updated_date;

                // Remove saved setting from array parameter now that we have updated the setting definition
                unset($savedSettings[$settingIndex[$setting->key]]);
            } else {
                // If a matching saved setting was NOT found, then set default value
                $definedSettings[$defKey]->setting_value = $definedSettings[$defKey]->value;
            }

            // Amend setting keys to what is expected in template
            $definedSettings[$defKey]->setting_key = $setting->key;
            $definedSettings[$defKey]->input_type = $definedSettings[$defKey]->inputType;

            // Include select options array
            if ($definedSettings[$defKey]->inputType === 'select') {
                $definedSettings[$defKey]->options = array_column($definedSettings[$defKey]->options, 'name', 'value');
            }

            // Add setting catagory. Not needed for page settings, but not in the way either
            $definedSettings[$defKey]->category = 'custom';

            // Remove JSON keys to avoid confusion in template
            unset($definedSettings[$defKey]->key);
            unset($definedSettings[$defKey]->value);
            unset($definedSettings[$defKey]->inputType);
        }

        // Check remaining saved settings for orphaned settings.
        array_walk($savedSettings, function(&$row) use ($pageSetting) {
            if ($pageSetting || (isset($row->category) && $row->category === 'custom')) {
                $row->orphaned = true;
            }
        });

        // Append defined settings to end of saved settings array and return
        return array_merge($savedSettings, $definedSettings);
    }
233296
protected function addModelSettings(array &$settings)
    {
        $settings['elementClass']  = 'Date';
        $settings['dateFormat']    = $this->getDateFormat();
        $settings['storageFormat'] = $this->getStorageFormat();
        $settings['type']          = $this->type;
    }