PersistentDatabaseLockBackend.php 971 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Drupal\Core\Lock;
  3. use Drupal\Core\Database\Connection;
  4. /**
  5. * Defines the persistent database lock backend. This backend is global for this
  6. * Drupal installation.
  7. *
  8. * @ingroup lock
  9. */
  10. class PersistentDatabaseLockBackend extends DatabaseLockBackend {
  11. /**
  12. * Constructs a new PersistentDatabaseLockBackend.
  13. *
  14. * @param \Drupal\Core\Database\Connection $database
  15. * The database connection.
  16. */
  17. public function __construct(Connection $database) {
  18. // Do not call the parent constructor to avoid registering a shutdown
  19. // function that releases all the locks at the end of a request.
  20. $this->database = $database;
  21. // Set the lockId to a fixed string to make the lock ID the same across
  22. // multiple requests. The lock ID is used as a page token to relate all the
  23. // locks set during a request to each other.
  24. // @see \Drupal\Core\Lock\LockBackendInterface::getLockId()
  25. $this->lockId = 'persistent';
  26. }
  27. }