You are here

public function Crontab::formatLabelVerbose in Ultimate Cron 8.2

Label for schedule.

Parameters

\Drupal\ultimate_cron\Entity\CronJob $job: The job whose label should be formatted.

Overrides SchedulerInterface::formatLabelVerbose

File

src/Plugin/ultimate_cron/Scheduler/Crontab.php, line 41

Class

Crontab
Crontab scheduler.

Namespace

Drupal\ultimate_cron\Plugin\ultimate_cron\Scheduler

Code

public function formatLabelVerbose(CronJob $job) {
  $parsed = '';
  $next_schedule = NULL;
  $time = REQUEST_TIME;
  $skew = $this
    ->getSkew($job);
  foreach ($this->configuration['rules'] as $rule) {
    $cron = CronRule::factory($rule, $time, $skew);
    $parsed .= $cron
      ->parseRule() . "\n";
    $result = $cron
      ->getNextSchedule();
    $next_schedule = is_null($next_schedule) || $next_schedule > $result ? $result : $next_schedule;
    $result = $cron
      ->getLastSchedule();
    if ($time < $result + $this->configuration['catch_up']) {
      $result = floor($time / 60) * 60 + 60;
      $next_schedule = $next_schedule > $result ? $result : $next_schedule;
    }
  }
  $parsed .= t('Next scheduled run at @datetime', array(
    '@datetime' => \Drupal::service('date.formatter')
      ->format($next_schedule, 'custom', 'Y-m-d H:i:s'),
  ));
  return $parsed;
}