You are here

class BlazySettings in Blazy 8.2

Provides settings object.

@todo convert settings into BlazySettings instance at blazy:8.3 if you can.

Hierarchy

  • class \Drupal\blazy\BlazySettings implements \Drupal\blazy\Countable

Expanded class hierarchy of BlazySettings

File

src/BlazySettings.php, line 10

Namespace

Drupal\blazy
View source
class BlazySettings implements \Countable {

  /**
   * Stores the settings.
   *
   * @var \stdClass[]
   */
  protected $storage = [];

  /**
   * Creates a new BlazySettings instance.
   *
   * @param \stdClass[] $storage
   *   The storage.
   */
  public function __construct(array $storage) {
    $this->storage = $storage;
  }

  /**
   * Counts total items.
   */
  public function count() {
    return count($this->storage);
  }

  /**
   * Gets values from a key.
   */
  public function get($id) {
    return isset($this->storage[$id]) ? $this->storage[$id] : NULL;
  }

  /**
   * Sets values for a key.
   */
  public function set($key, $value = NULL) {
    if (is_array($key) && empty($value)) {
      foreach ($key as $k => $v) {
        $this->storage[$k] = $v;
      }
    }
    else {
      $this->storage[$key] = $value;
    }
    return $this;
  }

  /**
   * Returns the whole array.
   */
  public function storage() {
    return $this->storage;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlazySettings::$storage protected property Stores the settings.
BlazySettings::count public function Counts total items.
BlazySettings::get public function Gets values from a key.
BlazySettings::set public function Sets values for a key.
BlazySettings::storage public function Returns the whole array.
BlazySettings::__construct public function Creates a new BlazySettings instance.