You are here

public function BlazyManagerBase::config in Blazy 7

Returns any config, or keyed by the $key.

@todo use D8 approach for this.

3 calls to BlazyManagerBase::config()
BlazyManager::config in src/BlazyManager.php
Returns any config, or keyed by the $key.
BlazyManagerBase::attach in src/BlazyManagerBase.php
Returns array of needed assets suitable for #attached property.
BlazyManagerBase::getIoSettings in src/BlazyManagerBase.php
Returns drupalSettings for IO.
1 method overrides BlazyManagerBase::config()
BlazyManager::config in src/BlazyManager.php
Returns any config, or keyed by the $key.

File

src/BlazyManagerBase.php, line 45

Class

BlazyManagerBase
Implements BlazyManagerInterface.

Namespace

Drupal\blazy

Code

public function config($key = '', $default = NULL, $id = 'blazy.settings', array $defaults = []) {
  $config = variable_get($id, $defaults);

  // Somebody likes deleting variables for no apparent reasons, make em happy.
  if (!$config) {
    return $default;
  }
  if (!$key) {
    return $config;
  }

  // Support once level array with dot notation.
  if (strpos($key, ".") !== FALSE) {
    $parts = explode(".", $key);

    // @todo $value = NestedArray::getValue($config, (array) $parts);
    $value = isset($config[$parts[0]][$parts[1]]) ? $config[$parts[0]][$parts[1]] : $default;
  }
  else {
    $value = isset($config[$key]) ? $config[$key] : $default;
  }
  return $value;
}