Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Key.php

class Key

Same name in this branch
  1. 11.1.x vendor/lullabot/php-webdriver/lib/WebDriver/Key.php \WebDriver\Key

Key is a container for the state of the locks in stores.

@author Jérémy Derussé <jeremy@derusse.com>

Hierarchy

  • class \Symfony\Component\Lock\Key

Expanded class hierarchy of Key

15 files declare their use of Key
CombinedStore.php in vendor/symfony/lock/Store/CombinedStore.php
DatabaseTableTrait.php in vendor/symfony/lock/Store/DatabaseTableTrait.php
DoctrineDbalPostgreSqlStore.php in vendor/symfony/lock/Store/DoctrineDbalPostgreSqlStore.php
DoctrineDbalStore.php in vendor/symfony/lock/Store/DoctrineDbalStore.php
ExpiringStoreTrait.php in vendor/symfony/lock/Store/ExpiringStoreTrait.php

... See full list

32 string references to 'Key'
AccountSettingsForm::buildForm in core/modules/user/src/AccountSettingsForm.php
Form constructor.
ArrayItem::getSubNodeNames in vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php
Gets the names of the sub nodes.
ckeditor5.schema.yml in core/modules/ckeditor5/config/schema/ckeditor5.schema.yml
core/modules/ckeditor5/config/schema/ckeditor5.schema.yml
claro_form_system_modules_alter in core/themes/claro/claro.theme
Implements hook_form_FORM_ID_alter() for the system_modules form.
ClassFilesSniff::drupalParseInfoFormat in vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php
Parses a Drupal info file. Copied from Drupal core drupal_parse_info_format().

... See full list

File

vendor/symfony/lock/Key.php, line 21

Namespace

Symfony\Component\Lock
View source
final class Key {
    private ?float $expiringTime = null;
    private array $state = [];
    private bool $serializable = true;
    public function __construct(string $resource) {
    }
    public function __toString() : string {
        return $this->resource;
    }
    public function hasState(string $stateKey) : bool {
        return isset($this->state[$stateKey]);
    }
    public function setState(string $stateKey, mixed $state) : void {
        $this->state[$stateKey] = $state;
    }
    public function removeState(string $stateKey) : void {
        unset($this->state[$stateKey]);
    }
    public function getState(string $stateKey) : mixed {
        return $this->state[$stateKey];
    }
    public function markUnserializable() : void {
        $this->serializable = false;
    }
    public function resetLifetime() : void {
        $this->expiringTime = null;
    }
    
    /**
     * @param float $ttl the expiration delay of locks in seconds
     */
    public function reduceLifetime(float $ttl) : void {
        $newTime = microtime(true) + $ttl;
        if (null === $this->expiringTime || $this->expiringTime > $newTime) {
            $this->expiringTime = $newTime;
        }
    }
    
    /**
     * Returns the remaining lifetime in seconds.
     */
    public function getRemainingLifetime() : ?float {
        return null === $this->expiringTime ? null : $this->expiringTime - microtime(true);
    }
    public function isExpired() : bool {
        return null !== $this->expiringTime && $this->expiringTime <= microtime(true);
    }
    public function __sleep() : array {
        if (!$this->serializable) {
            throw new UnserializableKeyException('The key cannot be serialized.');
        }
        return [
            'resource',
            'expiringTime',
            'state',
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary
Key::$expiringTime private property
Key::$serializable private property
Key::$state private property
Key::getRemainingLifetime public function Returns the remaining lifetime in seconds.
Key::getState public function
Key::hasState public function
Key::isExpired public function
Key::markUnserializable public function
Key::reduceLifetime public function
Key::removeState public function
Key::resetLifetime public function
Key::setState public function
Key::__construct public function
Key::__sleep public function
Key::__toString public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal