diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 6d53cab..2ab32f9 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -548,7 +548,8 @@ function entity_list_controller($entity_type) { if (!isset($instances[$entity_type])) { $info = entity_get_info($entity_type); $class = $info['list controller class']; - $controllers[$entity_type] = new $class($entity_type); + $storage = entity_get_controller($entity_type); + $controllers[$entity_type] = new $class($entity_type, $storage); } return $controllers[$entity_type]; } diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index 8fa354b..3a111fe 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -40,10 +40,12 @@ class EntityListController implements EntityListControllerInterface { * * @param string $entity_type. * The type of entity to be listed. + * @param Drupal\Core\Entity\EntityStorageControllerInterface $storage. + * The entity storage controller class. */ - public function __construct($entity_type) { + public function __construct($entity_type, EntityStorageControllerInterface $storage) { $this->entityType = $entity_type; - $this->storage = entity_get_controller($this->entityType); + $this->storage = $storage; $this->entityInfo = entity_get_info($this->entityType); } @@ -95,7 +97,10 @@ public function getPath() { } /** - * Implements Drupal\Core\Entity\EntityListControllerInterface::buildHeader(). + * Builds the header row. + * + * @return array + * An array of header strings. */ public function buildHeader() { $row['label'] = t('Label'); @@ -105,7 +110,13 @@ public function buildHeader() { } /** - * Implements Drupal\Core\Entity\EntityListControllerInterface::buildRow(). + * Builds an array of data for each row. + * + * @param Drupal\Core\Entity\EntityInterface $entity + * The entity for this row of the list. + * + * @return array + * An array of fields to use for this entity. */ public function buildRow(EntityInterface $entity) { $row['label'] = $entity->label(); @@ -116,7 +127,13 @@ public function buildRow(EntityInterface $entity) { } /** - * Implements Drupal\Core\Entity\EntityListControllerInterface::buildOperations(). + * Renders a list of operation links. + * + * @param Drupal\Core\Entity\EntityInterface $entity + * The entity on which the linked operations will be performed. + * + * @return array + * A renderable array of operation links. */ public function buildOperations(EntityInterface $entity) { // Retrieve and sort operations. diff --git a/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php index 3b49301..85790c3 100644 --- a/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php @@ -23,54 +23,31 @@ public function getStorageController(); /** * Loads entities of this type from storage for listing. * + * This allows the controller to manipulate the list, like filtering or + * sorting the loaded entities. + * * @return array * An array of entities implementing Drupal\Core\Entity\EntityInterface. */ public function load(); /** - * Provides an array of information to render the operation links. + * Provides an array of information to build a list of operation links. * * @param Drupal\Core\Entity\EntityInterface $entity * The entity the operations are for. * * @return array - * A array of operation link data to use in - * EntityListControllerInterface::buildOperations(). + * 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. + * - href: The path for the operation. + * - options: An array of URL options for the path. + * - weight: The weight of this operation. */ public function getOperations(EntityInterface $entity); /** - * Builds the header row. - * - * @return array - * An array of header strings. - */ - public function buildHeader(); - - /** - * Builds an array of data for each row. - * - * @param Drupal\Core\Entity\EntityInterface $entity - * The entity for this row of the list. - * - * @return array - * An array of fields to use for this entity. - */ - public function buildRow(EntityInterface $entity); - - /** - * Renders a list of operation links. - * - * @param Drupal\Core\Entity\EntityInterface $entity - * The entity on which the linked operations will be performed. - * - * @return array - * A renderable array of operation links. - */ - public function buildOperations(EntityInterface $entity); - - /** * Renders the list page markup to be output. * * @return string