lullabot / drupal-symfony-lock
使用 Drupal 的锁后端与 Symfony 的锁定 API。
1.2.0
2023-09-06 13:46 UTC
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-09-06 16:02:50 UTC
README
你想要在你的 Drupal 网站中使用需要 Symfony 的 锁定组件 的 PHP 库吗?这个库将 Drupal 的 LockBackendInterface 映射到 Symfony StoreInterface。
用法
在你的 Drupal 模块中需要这个库
$ composer require lullabot/drupal-symfony-lock
从 Drupal 容器注入锁服务,并在构建此类时使用它
<?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);