You are here

public function WorkflowTransitionListBuilder::load in Workflow 8

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/WorkflowTransitionListBuilder.php, line 49

Class

WorkflowTransitionListBuilder
Defines a class to build a draggable listing of Workflow State entities.

Namespace

Drupal\workflow

Code

public function load() {

  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  $entity = $this->workflow_entity;

  // N.B. This is a custom variable.
  $entity_type = $entity
    ->getEntityTypeId();
  $entity_id = $entity
    ->id();
  $field_name = workflow_url_get_field_name();

  // @todo D8: document $limit. Should be used in pager, not in load().
  // N.B. Using the provided default History view is recommended.
  $this->limit = \Drupal::config('workflow.settings')
    ->get('workflow_states_per_page');
  $limit = $this->limit;

  // Get Transitions with highest timestamp first.
  $entities = WorkflowTransition::loadMultipleByProperties($entity_type, [
    $entity_id,
  ], [], $field_name, '', $limit, 'DESC');
  return $entities;
}