EntityListBuilderInterface.php 1.53 KB
Newer Older
1 2 3 4 5
<?php

namespace Drupal\Core\Entity;

/**
6
 * Defines an interface to build entity listings.
7
 */
8
interface EntityListBuilderInterface {
9 10

  /**
11
   * Gets the entity storage.
12
   *
13 14
   * @return \Drupal\Core\Entity\EntityStorageInterface
   *   The storage used by this list builder.
15
   */
16
  public function getStorage();
17 18 19 20

  /**
   * Loads entities of this type from storage for listing.
   *
21
   * This allows the implementation to manipulate the listing, like filtering or
22 23
   * sorting the loaded entities.
   *
24
   * @return \Drupal\Core\Entity\EntityInterface[]
25 26 27
   *   An array of entities implementing \Drupal\Core\Entity\EntityInterface
   *   indexed by their IDs. Returns an empty array if no matching entities are
   *   found.
28 29 30 31 32 33
   */
  public function load();

  /**
   * Provides an array of information to build a list of operation links.
   *
34
   * @param \Drupal\Core\Entity\EntityInterface $entity
35 36 37 38 39 40
   *   The entity the operations are for.
   *
   * @return array
   *   An associative array of operation link data for this list, keyed by
   *   operation name, containing the following key-value pairs:
   *   - title: The localized title of the operation.
41
   *   - url: An instance of \Drupal\Core\Url for the operation URL.
42 43 44 45 46
   *   - weight: The weight of this operation.
   */
  public function getOperations(EntityInterface $entity);

  /**
47
   * Builds a listing of entities for the given entity type.
48
   *
49
   * @return array
50 51
   *   A render array as expected by
   *   \Drupal\Core\Render\RendererInterface::render().
52 53 54 55
   */
  public function render();

}