3 namespace Drupal\Core\KeyValueStore;
5 use Drupal\Component\Serialization\SerializationInterface;
6 use Drupal\Core\Database\Connection;
9 * Defines the key/value store factory for the database backend.
11 class KeyValueDatabaseFactory implements KeyValueFactoryInterface {
14 * The serialization class to use.
16 * @var \Drupal\Component\Serialization\SerializationInterface
18 protected $serializer;
21 * The database connection to use.
23 * @var \Drupal\Core\Database\Connection
25 protected $connection;
28 * Constructs this factory object.
30 * @param \Drupal\Component\Serialization\SerializationInterface $serializer
31 * The serialization class to use.
32 * @param \Drupal\Core\Database\Connection $connection
33 * The Connection object containing the key-value tables.
35 public function __construct(SerializationInterface $serializer, Connection $connection) {
36 $this->serializer = $serializer;
37 $this->connection = $connection;
43 public function get($collection) {
44 return new DatabaseStorage($collection, $this->serializer, $this->connection);