lullabot / drupal-symfony-lock
Use Drupal's lock backends with Symfony's locking API.
Installs: 33 126
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: ^8.0
- drupal/core: ^9.1||^10
- symfony/lock: ^4.4||^6
Requires (Dev)
- drupal/coder: 8.3.13
- phpunit/phpunit: ^6.5||^9.5
- squizlabs/php_codesniffer: 3.6.0
This package is auto-updated.
Last update: 2024-12-06 16:32:10 UTC
README
Do you want to use a PHP library that requires Symfony's Lock Component in your Drupal site? This library maps Drupal's LockBackendInterface to a Symfony StoreInterface.
Usage
Require this library in your Drupal module:
$ composer require lullabot/drupal-symfony-lock
Inject lock service from the Drupal container, and use it when constructing this class:
<?php $backend = \Drupal::lock(); $store = new \Lullabot\DrupalSymfonyLock\DrupalStore($backend); $factory = new \Symfony\Component\Lock\Factory($store); $lock = $factory->createLock('lock-identifier', 10); // Blocking means this will throw an exception on failure. $lock->acquire(true);