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\blazyView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlazySettings:: |
protected | property | Stores the settings. | |
BlazySettings:: |
public | function | Counts total items. | |
BlazySettings:: |
public | function | Gets values from a key. | |
BlazySettings:: |
public | function | Sets values for a key. | |
BlazySettings:: |
public | function | Returns the whole array. | |
BlazySettings:: |
public | function | Creates a new BlazySettings instance. |