3 namespace Drupal\entityqueue;
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\EntityListBuilder;
9 * Defines a class that builds a listing of entity subqueues.
11 class EntitySubqueueListBuilder extends EntityListBuilder {
14 * The ID of the entity queue for which to list all subqueues.
16 * @var \Drupal\entityqueue\Entity\EntityQueue
21 * Sets the entity queue ID.
23 * @param string $queue_id
24 * The entity queue ID.
28 public function setQueueId($queue_id) {
29 $this->queueId = $queue_id;
35 * Loads entity IDs using a pager sorted by the entity id and optionally
39 * An array of entity IDs.
41 protected function getEntityIds() {
42 $query = $this->getStorage()->getQuery()
43 ->sort($this->entityType->getKey('id'));
45 // Only add the pager if a limit is specified.
47 $query->pager($this->limit);
51 $query->condition($this->entityType->getKey('bundle'), $this->queueId);
54 return $query->execute();
61 public function buildHeader() {
62 $header['label'] = $this->t('Subqueue');
63 $header['items'] = $this->t('Items');
65 return $header + parent::buildHeader();
71 public function buildRow(EntityInterface $entity) {
72 $row['label'] = $entity->label();
73 $row['items'] = $this->t('@count items', ['@count' => count($entity->items)]);
75 return $row + parent::buildRow($entity);
81 public function getDefaultOperations(EntityInterface $entity) {
82 $operations = parent::getDefaultOperations($entity);
84 $operations['edit']['title'] = $this->t('Edit items');