Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / entityqueue / src / EntityQueueListBuilder.php
index 76a13df3f32bb313aa12d94b5e8999773b09ada5..77fa85da0bdfbb84d5ce0e7a7223d62fe1a08285 100644 (file)
@@ -2,10 +2,12 @@
 
 namespace Drupal\entityqueue;
 
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Session\AccountInterface;
 use Drupal\entityqueue\Entity\EntitySubqueue;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
@@ -21,6 +23,11 @@ class EntityQueueListBuilder extends ConfigEntityListBuilder {
    */
   protected $entityTypeManager;
 
+  /**
+   * {@inheritdoc}
+   */
+  protected $limit = FALSE;
+
   /**
    * Constructs a new class instance.
    *
@@ -49,11 +56,16 @@ class EntityQueueListBuilder extends ConfigEntityListBuilder {
    * {@inheritdoc}
    */
   public function load() {
-    $entities = array(
-      'enabled' => array(),
-      'disabled' => array(),
-    );
+    $entities = [
+      'enabled' => [],
+      'disabled' => [],
+    ];
+    /** @var \Drupal\entityqueue\EntityQueueInterface $entity */
     foreach (parent::load() as $entity) {
+      // Don't display queues which can not be edited by the user.
+      if (!$entity->access('update')) {
+        continue;
+      }
       if ($entity->status()) {
         $entities['enabled'][] = $entity;
       }
@@ -87,7 +99,7 @@ class EntityQueueListBuilder extends ConfigEntityListBuilder {
         'handler' => $entity->getHandlerPlugin()->getPluginDefinition()['title'],
         'items' => $this->getQueueItemsStatus($entity),
       ] + parent::buildRow($entity),
-      'title' => $this->t('Machine name: @name', array('@name' => $entity->id())),
+      'title' => $this->t('Machine name: @name', ['@name' => $entity->id()]),
     ];
 
     return $row;
@@ -102,25 +114,29 @@ class EntityQueueListBuilder extends ConfigEntityListBuilder {
     $build['#type'] = 'container';
     $build['#attributes']['id'] = 'entity-queue-list';
     $build['#attached']['library'][] = 'core/drupal.ajax';
+    $build['#cache'] = [
+      'contexts' => Cache::mergeContexts($this->entityType->getListCacheContexts(), ['user.permissions']),
+      'tags' => $this->entityType->getListCacheTags(),
+    ];
 
-    $build['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', array(), array('context' => 'Plural')) . '</h2>';
-    $build['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', array(), array('context' => 'Plural')) . '</h2>';
+    $build['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', [], ['context' => 'Plural']) . '</h2>';
+    $build['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', [], ['context' => 'Plural']) . '</h2>';
 
-    foreach (array('enabled', 'disabled') as $status) {
+    foreach (['enabled', 'disabled'] as $status) {
       $build[$status]['#type'] = 'container';
-      $build[$status]['#attributes'] = array('class' => array('entity-queue-list-section', $status));
-      $build[$status]['table'] = array(
+      $build[$status]['#attributes'] = ['class' => ['entity-queue-list-section', $status]];
+      $build[$status]['table'] = [
         '#type' => 'table',
-        '#attributes' => array(
-          'class' => array('entity-queue-listing-table'),
-        ),
+        '#attributes' => [
+          'class' => ['entity-queue-listing-table'],
+        ],
         '#header' => $this->buildHeader(),
-        '#rows' => array(),
+        '#rows' => [],
         '#cache' => [
           'contexts' => $this->entityType->getListCacheContexts(),
           'tags' => $this->entityType->getListCacheTags(),
         ],
-      );
+      ];
       foreach ($entities[$status] as $entity) {
         $build[$status]['table']['#rows'][$entity->id()] = $this->buildRow($entity);
       }
@@ -144,7 +160,7 @@ class EntityQueueListBuilder extends ConfigEntityListBuilder {
     }
 
     // Add AJAX functionality to enable/disable operations.
-    foreach (array('enable', 'disable') as $op) {
+    foreach (['enable', 'disable'] as $op) {
       if (isset($operations[$op])) {
         $operations[$op]['url'] = $entity->toUrl($op);
         // Enable and disable operations should use AJAX.