QueryFactory::getValues

protected QueryFactory::getValues(Config $config, $key, $get_method, array $parts, $start = 0)

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.

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;
}
doc_Drupal
2016-10-29 09:35:54
Comments
Leave a Comment

Please login to continue.