Skip to content
Use Drupal's lock backends with Symfony's locking API
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
src
tests/src/Unit
.gitignore
CHANGELOG.md
LICENSE.txt
README.md
composer.json
phpunit.xml.dist

README.md

Drupal Symfony Lock

CircleCI Maintainability Test Coverage

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);
You can’t perform that action at this time.