You are here

protected function QueryFactory::getValues in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php \Drupal\Core\Config\Entity\Query\QueryFactory::getValues()

Finds all the values for a configuration key in a configuration object.

Parameters

\Drupal\Core\Config\Config $config: The configuration object.

string $key: The current key being checked.

string $get_method: Which method on the config object to call to get the value.

array $parts: All the parts of a configuration key we are checking.

int $start: Which position of $parts we are processing. Defaults to 0.

Return value

array|null The array of configuration values the match the provided key. NULL if the configuration object does not have a value that corresponds to the key.

1 call to QueryFactory::getValues()
QueryFactory::getKeys in core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
Creates lookup keys for configuration data.

File

core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php, line 197

Class

QueryFactory
Provides a factory for creating entity query objects for the config backend.

Namespace

Drupal\Core\Config\Entity\Query

Code

protected function getValues(Config $config, $key, $get_method, array $parts, $start = 0) {
  $value = $config
    ->{$get_method}($key);
  if (is_array($value)) {
    $new_value = [];
    $start++;
    if (!isset($parts[$start])) {

      // The configuration object does not have a value that corresponds to
      // the key.
      return NULL;
    }
    foreach (array_keys($value) as $key_bit) {
      $new_key = $key . '.' . $key_bit;
      if (!empty($parts[$start])) {
        $new_key .= '.' . $parts[$start];
      }
      $new_value[] = $this
        ->getValues($config, $new_key, $get_method, $parts, $start);
    }
    $value = $new_value;
  }
  return $value;
}