Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Config / Config.php
index 584feb7c5375525b9c9c361b9ea3461cbe0fd65c..7299d5e642cdc5afe6a0cf8df90b81886ccd44d5 100644 (file)
@@ -303,4 +303,42 @@ class Config extends StorableConfigBase {
     }
   }
 
+  /**
+   * Determines if overrides are applied to a key for this configuration object.
+   *
+   * @param string $key
+   *   (optional) A string that maps to a key within the configuration data.
+   *   For instance in the following configuration array:
+   *   @code
+   *   array(
+   *     'foo' => array(
+   *       'bar' => 'baz',
+   *     ),
+   *   );
+   *   @endcode
+   *   A key of 'foo.bar' would map to the string 'baz'. However, a key of 'foo'
+   *   would map to the array('bar' => 'baz').
+   *   If not supplied TRUE will be returned if there are any overrides at all
+   *   for this configuration object.
+   *
+   * @return bool
+   *   TRUE if there are any overrides for the key, otherwise FALSE.
+   */
+  public function hasOverrides($key = '') {
+    if (empty($key)) {
+      return !(empty($this->moduleOverrides) && empty($this->settingsOverrides));
+    }
+    else {
+      $parts = explode('.', $key);
+      $override_exists = FALSE;
+      if (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) {
+        $override_exists = NestedArray::keyExists($this->moduleOverrides, $parts);
+      }
+      if (!$override_exists && isset($this->settingsOverrides) && is_array($this->settingsOverrides)) {
+        $override_exists = NestedArray::keyExists($this->settingsOverrides, $parts);
+      }
+      return $override_exists;
+    }
+  }
+
 }