Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / entityqueue / src / EntitySubqueueListBuilder.php
1 <?php
2
3 namespace Drupal\entityqueue;
4
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\EntityListBuilder;
7
8 /**
9  * Defines a class that builds a listing of entity subqueues.
10  */
11 class EntitySubqueueListBuilder extends EntityListBuilder {
12
13   /**
14    * The ID of the entity queue for which to list all subqueues.
15    *
16    * @var \Drupal\entityqueue\Entity\EntityQueue
17    */
18   protected $queueId;
19
20   /**
21    * Sets the entity queue ID.
22    *
23    * @param string $queue_id
24    *   The entity queue ID.
25    *
26    * @return $this
27    */
28   public function setQueueId($queue_id) {
29     $this->queueId = $queue_id;
30
31     return $this;
32   }
33
34   /**
35    * Loads entity IDs using a pager sorted by the entity id and optionally
36    * filtered by bundle.
37    *
38    * @return array
39    *   An array of entity IDs.
40    */
41   protected function getEntityIds() {
42     $query = $this->getStorage()->getQuery()
43       ->sort($this->entityType->getKey('id'));
44
45     // Only add the pager if a limit is specified.
46     if ($this->limit) {
47       $query->pager($this->limit);
48     }
49
50     if ($this->queueId) {
51       $query->condition($this->entityType->getKey('bundle'), $this->queueId);
52     }
53
54     return $query->execute();
55   }
56
57
58   /**
59    * {@inheritdoc}
60    */
61   public function buildHeader() {
62     $header['label'] = $this->t('Subqueue');
63     $header['items'] = $this->t('Items');
64
65     return $header + parent::buildHeader();
66   }
67
68   /**
69    * {@inheritdoc}
70    */
71   public function buildRow(EntityInterface $entity) {
72     $row['label'] = $entity->label();
73     $row['items'] = $this->t('@count items', ['@count' => count($entity->items)]);
74
75     return $row + parent::buildRow($entity);
76   }
77
78   /**
79    * {@inheritdoc}
80    */
81   public function getDefaultOperations(EntityInterface $entity) {
82     $operations = parent::getDefaultOperations($entity);
83
84     $operations['edit']['title'] = $this->t('Edit items');
85
86     return $operations;
87   }
88
89 }