function DatabaseStorageExpirable::__construct

Same name in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::__construct()
  2. 8.9.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::__construct()
  3. 11.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::__construct()

Overrides Drupal\Core\KeyValueStore\StorageBase::__construct().

Parameters

string $collection: The name of the collection holding key and value pairs.

\Drupal\Component\Serialization\SerializationInterface $serializer: The serialization class to use.

\Drupal\Core\Database\Connection $connection: The database connection to use.

\Drupal\Component\Datetime\TimeInterface|string|null $time: The time service.

string $table: The name of the SQL table to use, defaults to key_value_expire.

Overrides DatabaseStorage::__construct

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php, line 31

Class

DatabaseStorageExpirable
Defines a default key/value store implementation for expiring items.

Namespace

Drupal\Core\KeyValueStore

Code

public function __construct($collection, SerializationInterface $serializer, Connection $connection, TimeInterface|string|null $time = NULL, $table = 'key_value_expire') {
    if (is_null($time)) {
        @trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
        $this->time = \Drupal::time();
    }
    elseif (is_string($time)) {
        @trigger_error('Calling ' . __METHOD__ . ' with the $table as 4th argument is deprecated in drupal:10.3.0 and it will be the 5th argument in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
        $table = $time;
        $this->time = \Drupal::time();
    }
    parent::__construct($collection, $serializer, $connection, $table);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.