Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / KeyValueStore / StorageBase.php
1 <?php
2
3 namespace Drupal\Core\KeyValueStore;
4
5 /**
6  * Provides a base class for key/value storage implementations.
7  */
8 abstract class StorageBase implements KeyValueStoreInterface {
9
10   /**
11    * The name of the collection holding key and value pairs.
12    *
13    * @var string
14    */
15   protected $collection;
16
17   /**
18    * {@inheritdoc}
19    */
20   public function __construct($collection) {
21     $this->collection = $collection;
22   }
23
24   /**
25    * {@inheritdoc}
26    */
27   public function getCollectionName() {
28     return $this->collection;
29   }
30
31   /**
32    * {@inheritdoc}
33    */
34   public function get($key, $default = NULL) {
35     $values = $this->getMultiple([$key]);
36     return isset($values[$key]) ? $values[$key] : $default;
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function setMultiple(array $data) {
43     foreach ($data as $key => $value) {
44       $this->set($key, $value);
45     }
46   }
47
48   /**
49    * {@inheritdoc}
50    */
51   public function delete($key) {
52     $this->deleteMultiple([$key]);
53   }
54
55 }