You are here

function background_process_unlock in Background Process 8

Same name and namespace in other branches
  1. 6 background_process.module \background_process_unlock()
  2. 7 background_process.module \background_process_unlock()

Unlock background process.

5 calls to background_process_unlock()
background_process_ass_cron_alter in background_process_ass/background_process_ass.module
Implements hook_cron_alter().
background_process_cron in ./background_process.module
Implements hook_cron().
background_process_cron_alter in ./background_process.module
Implements hook_cron_alter().
DefaultController::backgroundProcessServiceUnlock in src/Controller/DefaultController.php
Implements Background Process Service Unlock.
_background_process_ass_unlock in background_process_ass/background_process_ass.module
Implements to Unlock Process Ass.

File

./background_process.module, line 716
This module implements a framework for calling funtions in the background.

Code

function background_process_unlock($handle, $msg = NULL, $start = NULL) {
  $process = background_process_get_process($handle);
  if ($process && (!isset($start) || $start === $process->start)) {

    // Unlock the process.
    if (background_process_remove_process($process->handle, $process->start)) {
      $user = \Drupal::currentUser();
      $username = $user->uid ? $user->name : t('anonymous');
      \Drupal::moduleHandler()
        ->invokeAll('background_process_shutdown', [
        $process,
        $msg ? $msg : t('Manually unlocked by !name', [
          '!name' => $username,
        ]),
      ]);
      return TRUE;
    }
  }
  return FALSE;
}