Commit a9d248a2 authored by catch's avatar catch

Issue #2160495 by damiankloip: Add a KeyValueExpirableFactoryInterface.

parent a4f85eb4
......@@ -14,8 +14,7 @@
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\HttpKernel;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactory;
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -124,7 +123,7 @@ class FormBuilder implements FormBuilderInterface {
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_expirable_factory
* @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $key_value_expirable_factory
* The keyvalue expirable factory.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
......@@ -137,7 +136,7 @@ class FormBuilder implements FormBuilderInterface {
* @param \Drupal\Core\HttpKernel $http_kernel
* The HTTP kernel.
*/
public function __construct(ModuleHandlerInterface $module_handler, KeyValueFactoryInterface $key_value_expirable_factory, EventDispatcherInterface $event_dispatcher, UrlGeneratorInterface $url_generator, TranslationInterface $translation_manager, CsrfTokenGenerator $csrf_token = NULL, HttpKernel $http_kernel = NULL) {
public function __construct(ModuleHandlerInterface $module_handler, KeyValueExpirableFactoryInterface $key_value_expirable_factory, EventDispatcherInterface $event_dispatcher, UrlGeneratorInterface $url_generator, TranslationInterface $translation_manager, CsrfTokenGenerator $csrf_token = NULL, HttpKernel $http_kernel = NULL) {
$this->moduleHandler = $module_handler;
$this->keyValueExpirableFactory = $key_value_expirable_factory;
$this->eventDispatcher = $event_dispatcher;
......
......@@ -9,13 +9,11 @@
use Drupal\Core\DestructableInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Database;
use Drupal\Core\KeyValueStore\KeyValueDatabaseFactory;
/**
* Defines the key/value store factory for the database backend.
*/
class KeyValueDatabaseExpirableFactory extends KeyValueDatabaseFactory implements DestructableInterface {
class KeyValueDatabaseExpirableFactory implements KeyValueExpirableFactoryInterface, DestructableInterface {
/**
* Holds references to each instantiation so they can be terminated.
......@@ -24,6 +22,24 @@ class KeyValueDatabaseExpirableFactory extends KeyValueDatabaseFactory implement
*/
protected $storages;
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* Constructs this factory object.
*
*
* @param \Drupal\Core\Database\Connection $connection
* The Connection object containing the key-value tables.
*/
function __construct(Connection $connection) {
$this->connection = $connection;
}
/**
* {@inheritdoc}
*/
......
......@@ -12,7 +12,7 @@
/**
* Defines the key/value store factory.
*/
class KeyValueExpirableFactory extends KeyValueFactory {
class KeyValueExpirableFactory extends KeyValueFactory implements KeyValueExpirableFactoryInterface {
const DEFAULT_SERVICE = 'keyvalue.expirable.database';
......
<?php
/**
* @file
* Contains \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface.
*/
namespace Drupal\Core\KeyValueStore;
/**
* Defines the expirable key/value store factory interface.
*/
interface KeyValueExpirableFactoryInterface {
/**
* Constructs a new expirable key/value store for a given collection name.
*
* @param string $collection
* The name of the collection holding key and value pairs.
*
* @return \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface
* An expirable key/value store implementation for the given $collection.
*/
public function get($collection);
}
......@@ -10,7 +10,7 @@
/**
* Defines the key/value store factory for the null backend.
*/
class KeyValueNullExpirableFactory implements KeyValueFactoryInterface {
class KeyValueNullExpirableFactory implements KeyValueExpirableFactoryInterface {
/**
* {@inheritdoc}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment