public function JobController::unlockCronJob in Ultimate Cron 8.2
Unlocks a single cron job.
Parameters
\Drupal\ultimate_cron\Entity\CronJob $ultimate_cron_job: The cron job which will be unlocked.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse Redirects to the job listing after running a job.
1 string reference to 'JobController::unlockCronJob'
File
- src/
Controller/ JobController.php, line 97
Class
- JobController
- A controller to interact with CronJob entities.
Namespace
Drupal\ultimate_cron\ControllerCode
public function unlockCronJob(CronJob $ultimate_cron_job) {
$lock_id = $ultimate_cron_job
->isLocked();
$name = $ultimate_cron_job
->label();
// Unlock the process.
if ($ultimate_cron_job
->unlock($lock_id, TRUE)) {
$user = \Drupal::currentUser();
\Drupal::logger('ultimate_cron')
->warning('@name manually unlocked by user @username (@uid)', array(
'@name' => $ultimate_cron_job
->id(),
'@username' => $user
->getDisplayName(),
'@uid' => $user
->id(),
));
$this
->messenger()
->addStatus($this
->t('Cron job @name unlocked successfully.', [
'@name' => $name,
]));
}
else {
$this
->messenger()
->addError($this
->t('Could not unlock cron job @name', [
'@name' => $name,
]));
}
return $this
->redirect('entity.ultimate_cron_job.collection');
}