You are here

class Config in Backup and Migrate 5.0.x

A basic configuration manager with very little logic in it.

@package Drupal\backup_migrate\Core\Config

Hierarchy

Expanded class hierarchy of Config

19 files declare their use of Config
backup_migrate.module in ./backup_migrate.module
Primary hook implementations for Backup Migrate.
CompressionFilter.php in src/Core/Filter/CompressionFilter.php
DatabaseSource.php in src/Core/Source/DatabaseSource.php
DBExcludeFilter.php in src/Core/Filter/DBExcludeFilter.php
DebugDestination.php in src/Core/Destination/DebugDestination.php

... See full list

File

src/Core/Config/Config.php, line 10

Namespace

Drupal\backup_migrate\Core\Config
View source
class Config implements ConfigInterface {

  /**
   * @var array
   */
  protected $config;

  /**
   * @param array $init
   */
  public function __construct(array $init = []) {
    if ($init instanceof ConfigInterface) {
      $this
        ->fromArray($init
        ->toArray());
    }
    elseif (is_array($init)) {
      $this
        ->fromArray($init);
    }
  }

  /**
   * Get a setting value.
   *
   * @param string $key
   *   The key for the setting.
   * @param mixed $default
   *   The default to return if the value does not exist.
   *
   * @return mixed
   *   The value of the setting.
   */
  public function get($key, $default = NULL) {
    return $this
      ->keyIsSet($key) ? $this->config[$key] : $default;
  }

  /**
   * Set a setting value.
   *
   * @param string $key
   *   The key for the setting.
   * @param mixed $value
   *   The value for the setting.
   */
  public function set($key, $value) {
    $this->config[$key] = $value;
  }

  /**
   * Determine if the given key has had a value set for it.
   *
   * @param string $key
   *   The array key to check for.
   *
   * @return bool
   *   Whether the key is defined.
   */
  public function keyIsSet($key) {
    return isset($this->config[$key]);
  }

  /**
   * Get all settings as an associative array.
   *
   * @return array
   *   All of the settings in this profile.
   */
  public function toArray() {
    return $this->config;
  }

  /**
   * Set all from an array.
   *
   * @param array $values
   *   An associative array of settings.
   */
  public function fromArray(array $values) {
    $this->config = $values;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Config::$config protected property
Config::fromArray public function Set all from an array. Overrides ConfigInterface::fromArray
Config::get public function Get a setting value. Overrides ConfigInterface::get
Config::keyIsSet public function Determine if the given key has had a value set for it. Overrides ConfigInterface::keyIsSet
Config::set public function Set a setting value. Overrides ConfigInterface::set
Config::toArray public function Get all settings as an associative array. Overrides ConfigInterface::toArray
Config::__construct public function