protected function 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!Entity!Query!QueryFactory.php/function/QueryFactory::getValues/8.1.x