You are here

protected static function AbstractSolrEntity::getAvailableOptions in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Entity/AbstractSolrEntity.php \Drupal\search_api_solr\Entity\AbstractSolrEntity::getAvailableOptions()

Get all available options.

Parameters

string $key:

string $default:

string $prefix:

Return value

string[] An array of options as strings.

4 calls to AbstractSolrEntity::getAvailableOptions()
SolrCache::getAvailableEnvironments in src/Entity/SolrCache.php
Get all available environments.
SolrFieldType::getAvailableDomains in src/Entity/SolrFieldType.php
Get all available domains form solr filed type configs.
SolrRequestDispatcher::getAvailableEnvironments in src/Entity/SolrRequestDispatcher.php
Get all available environments.
SolrRequestHandler::getAvailableEnvironments in src/Entity/SolrRequestHandler.php
Get all available environments.

File

src/Entity/AbstractSolrEntity.php, line 216

Class

AbstractSolrEntity
Defines the abstract base class for Solr config entities.

Namespace

Drupal\search_api_solr\Entity

Code

protected static function getAvailableOptions(string $key, string $default, string $prefix) {
  $options = [
    [
      $default,
    ],
  ];
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll($prefix) as $config_name) {
    $config = $config_factory
      ->get($config_name);
    $value = $config
      ->get($key);
    if (NULL !== $value) {
      $options[] = $value;
    }
  }
  $options = array_unique(array_merge(...$options));
  sort($options);
  return $options;
}