Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Config / Entity / ConfigEntityListBuilder.php
1 <?php
2
3 namespace Drupal\Core\Config\Entity;
4
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\EntityListBuilder;
7
8 /**
9  * Defines the default class to build a listing of configuration entities.
10  *
11  * @ingroup entity_api
12  */
13 class ConfigEntityListBuilder extends EntityListBuilder {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function load() {
19     $entity_ids = $this->getEntityIds();
20     $entities = $this->storage->loadMultipleOverrideFree($entity_ids);
21
22     // Sort the entities using the entity class's sort() method.
23     // See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
24     uasort($entities, [$this->entityType->getClass(), 'sort']);
25     return $entities;
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function getDefaultOperations(EntityInterface $entity) {
32     /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
33     $operations = parent::getDefaultOperations($entity);
34
35     if ($this->entityType->hasKey('status')) {
36       if (!$entity->status() && $entity->hasLinkTemplate('enable')) {
37         $operations['enable'] = [
38           'title' => t('Enable'),
39           'weight' => -10,
40           'url' => $this->ensureDestination($entity->toUrl('enable')),
41         ];
42       }
43       elseif ($entity->hasLinkTemplate('disable')) {
44         $operations['disable'] = [
45           'title' => t('Disable'),
46           'weight' => 40,
47           'url' => $this->ensureDestination($entity->toUrl('disable')),
48         ];
49       }
50     }
51
52     return $operations;
53   }
54
55 }