Mercurial > hg > isophonics-drupal-site
view core/lib/Drupal/Core/KeyValueStore/StorageBase.php @ 9:1fc0ff908d1f
Add another data file
author | Chris Cannam |
---|---|
date | Mon, 05 Feb 2018 12:34:32 +0000 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line source
<?php namespace Drupal\Core\KeyValueStore; /** * Provides a base class for key/value storage implementations. */ abstract class StorageBase implements KeyValueStoreInterface { /** * The name of the collection holding key and value pairs. * * @var string */ protected $collection; /** * {@inheritdoc} */ public function __construct($collection) { $this->collection = $collection; } /** * {@inheritdoc} */ public function getCollectionName() { return $this->collection; } /** * {@inheritdoc} */ public function get($key, $default = NULL) { $values = $this->getMultiple([$key]); return isset($values[$key]) ? $values[$key] : $default; } /** * {@inheritdoc} */ public function setMultiple(array $data) { foreach ($data as $key => $value) { $this->set($key, $value); } } /** * {@inheritdoc} */ public function delete($key) { $this->deleteMultiple([$key]); } }