You are here

public function ScheduleListBuilder::load in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/ScheduleListBuilder.php \Drupal\business_rules\ScheduleListBuilder::load()

Loads entities of this type from storage for listing.

This allows the implementation to manipulate the listing, like filtering or sorting the loaded entities.

Return value

\Drupal\Core\Entity\EntityInterface[] An array of entities implementing \Drupal\Core\Entity\EntityInterface indexed by their IDs. Returns an empty array if no matching entities are found.

Overrides EntityListBuilder::load

File

src/ScheduleListBuilder.php, line 135

Class

ScheduleListBuilder
Defines a class to build a listing of Schedule entities.

Namespace

Drupal\business_rules

Code

public function load() {
  $view_mode = \Drupal::request()
    ->get('view_mode');
  if ($view_mode == 'not_executed') {
    $entity_ids = \Drupal::entityQuery('business_rules_schedule')
      ->condition('status', 1, '<>')
      ->sort('scheduled', 'ASC')
      ->execute();
  }
  elseif ($view_mode == 'executed') {
    $entity_ids = \Drupal::entityQuery('business_rules_schedule')
      ->condition('status', 1, '=')
      ->sort('executed', 'DESC')
      ->execute();
  }
  else {
    $entity_ids = \Drupal::entityQuery('business_rules_schedule')
      ->sort('id', 'DESC')
      ->execute();
  }
  return $this->storage
    ->loadMultiple($entity_ids);
}