diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index b55d46b161..604b3b1ad7 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -85,7 +85,7 @@ public function get($key = '') { if (!isset($this->overriddenData)) { $this->setOverriddenData(); } - return self::extractKeyedData($this->overriddenData, $key); + return NestedArray::getValue($this->overriddenData, $key ? explode('.', $key) : []); } /** @@ -147,7 +147,7 @@ public function getOverrides($key = '') { if (empty($overrides)) { return NULL; } - return self::extractKeyedData($overrides, $key); + return NestedArray::getValue($overrides, $key ? explode('.', $key) : []); } /** @@ -285,8 +285,7 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { // Apply overrides. $original_data = $this->mergeOverridesWithData($original_data); } - - return self::extractKeyedData($original_data, $key); + return NestedArray::getValue($original_data, $key ? explode('.', $key) : []); } /** @@ -308,19 +307,4 @@ protected function mergeOverridesWithData(array $data) { return $data; } - /** - * Extract the value of a sub key in the data. - * - * @param array $data - * The configuration data. - * @param string $key - * A string that maps to a key within the configuration data. - * - * @return mixed - * The data at the key or NULL if it is not set. - */ - protected static function extractKeyedData(array $data, $key) { - return NestedArray::getValue($data, $key ? explode('.', $key) : []); - } - } diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index 4f445ea21c..bb8149642a 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -129,19 +129,7 @@ public static function validateName($name) { * The data that was requested. */ public function get($key = '') { - if (empty($key)) { - return $this->data; - } - else { - $parts = explode('.', $key); - if (count($parts) == 1) { - return isset($this->data[$key]) ? $this->data[$key] : NULL; - } - else { - $value = NestedArray::getValue($this->data, $parts, $key_exists); - return $key_exists ? $value : NULL; - } - } + return NestedArray::getValue($this->data, $key ? explode('.', $key) : []); } /**