function lock

Get locking layer instance.

Return value

Drupal\Core\Lock\LockBackendInterface

Related topics

2 calls to lock()
LockFunctionalTest::testBackendLockRelease in drupal/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php
Tests backend release functionality.
LockFunctionalTest::testBackendLockReleaseAll in drupal/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php
Tests backend release functionality.
1 string reference to 'lock'

File

drupal/core/includes/bootstrap.inc, line 3465
Functions that need to be loaded on every Drupal request.

Code

function lock() {
  $lock_backend =& drupal_static(__FUNCTION__);
  if (!isset($lock_backend)) {
    $class_name = variable_get('lock_backend', 'Drupal\\Core\\Lock\\DatabaseLockBackend');

    // Do not allow a WSOD here, if the class does not exists use the default
    // one.
    // @todo We should log failed class loading for debugging, but for that we
    //   need an early watchdog function that logs into a file if the database
    //   is not present.
    if (class_exists($class_name)) {
      $lock_backend = new $class_name();
    }
    else {
      $lock_backend = new DatabaseLockBackend();
    }
    drupal_register_shutdown_function(array(
      $lock_backend,
      'releaseAll',
    ));
  }
  return $lock_backend;
}