function SystemTestController::lockPersist

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::lockPersist()
  2. 10 core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::lockPersist()
  3. 9 core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::lockPersist()
  4. 8.9.x core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::lockPersist()

Creates a lock that will persist across requests.

Attributes

#[Route(path: '/system-test/lock-persist/{lock_name}', name: 'system_test.lock_persist', title: new TranslatableMarkup('Persistent lock acquire'), requirements: [ '_access' => 'TRUE', ], options: [ 'no_cache' => TRUE, ])]

Parameters

string $lock_name: The name of the persistent lock to acquire.

Return value

string The text to display.

File

core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php, line 320

Class

SystemTestController
Controller routines for system_test routes.

Namespace

Drupal\system_test\Controller

Code

public function lockPersist($lock_name) {
  if ($this->persistentLock
    ->acquire($lock_name)) {
    return [
      '#markup' => 'TRUE: Lock successfully acquired in SystemTestController::lockPersist()',
    ];
  }
  else {
    return [
      '#markup' => 'FALSE: Lock not acquired in SystemTestController::lockPersist()',
    ];
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.