You are here

public function CronJobListBuilder::getDefaultOperations in Ultimate Cron 8.2

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

src/CronJobListBuilder.php, line 93

Class

CronJobListBuilder
Defines a class to build a listing of cron jobs.

Namespace

Drupal\ultimate_cron

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  if ($entity
    ->status() && $entity
    ->isValid()) {
    if (!$entity
      ->isLocked()) {
      $operations += [
        'run' => [
          'title' => t('Run'),
          'weight' => 9,
          'url' => $entity
            ->toUrl('run'),
        ],
      ];
    }
    else {
      $operations += [
        'unlock' => [
          'title' => t('Unlock'),
          'weight' => 9,
          'url' => $entity
            ->toUrl('unlock'),
        ],
      ];
    }
  }
  $operations += [
    'logs' => [
      'title' => t('Logs'),
      'weight' => 10,
      'url' => $entity
        ->toUrl('logs'),
    ],
  ];

  // Invalid jobs can not be enabled nor disabled.
  if (!$entity
    ->isValid()) {
    unset($operations['disable']);
    unset($operations['enable']);
  }
  return $operations;
}