Commit a9d248a2 authored by catch's avatar catch

Issue #2160495 by damiankloip: Add a KeyValueExpirableFactoryInterface.

parent a4f85eb4
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
use Drupal\Core\Access\CsrfTokenGenerator; use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\HttpKernel; use Drupal\Core\HttpKernel;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactory; use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface;
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\StringTranslation\TranslationInterface;
...@@ -124,7 +123,7 @@ class FormBuilder implements FormBuilderInterface { ...@@ -124,7 +123,7 @@ class FormBuilder implements FormBuilderInterface {
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The 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. * The keyvalue expirable factory.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher. * The event dispatcher.
...@@ -137,7 +136,7 @@ class FormBuilder implements FormBuilderInterface { ...@@ -137,7 +136,7 @@ class FormBuilder implements FormBuilderInterface {
* @param \Drupal\Core\HttpKernel $http_kernel * @param \Drupal\Core\HttpKernel $http_kernel
* The 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->moduleHandler = $module_handler;
$this->keyValueExpirableFactory = $key_value_expirable_factory; $this->keyValueExpirableFactory = $key_value_expirable_factory;
$this->eventDispatcher = $event_dispatcher; $this->eventDispatcher = $event_dispatcher;
......
...@@ -9,13 +9,11 @@ ...@@ -9,13 +9,11 @@
use Drupal\Core\DestructableInterface; use Drupal\Core\DestructableInterface;
use Drupal\Core\Database\Connection; 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. * 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. * Holds references to each instantiation so they can be terminated.
...@@ -24,6 +22,24 @@ class KeyValueDatabaseExpirableFactory extends KeyValueDatabaseFactory implement ...@@ -24,6 +22,24 @@ class KeyValueDatabaseExpirableFactory extends KeyValueDatabaseFactory implement
*/ */
protected $storages; 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} * {@inheritdoc}
*/ */
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/** /**
* Defines the key/value store factory. * Defines the key/value store factory.
*/ */
class KeyValueExpirableFactory extends KeyValueFactory { class KeyValueExpirableFactory extends KeyValueFactory implements KeyValueExpirableFactoryInterface {
const DEFAULT_SERVICE = 'keyvalue.expirable.database'; 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 @@ ...@@ -10,7 +10,7 @@
/** /**
* Defines the key/value store factory for the null backend. * Defines the key/value store factory for the null backend.
*/ */
class KeyValueNullExpirableFactory implements KeyValueFactoryInterface { class KeyValueNullExpirableFactory implements KeyValueExpirableFactoryInterface {
/** /**
* {@inheritdoc} * {@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