class ConfigEntityListBuilder

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php \Drupal\Core\Config\Entity\ConfigEntityListBuilder
  2. 10 core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php \Drupal\Core\Config\Entity\ConfigEntityListBuilder
  3. 9 core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php \Drupal\Core\Config\Entity\ConfigEntityListBuilder
  4. 8.9.x core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php \Drupal\Core\Config\Entity\ConfigEntityListBuilder

Defines the default class to build a listing of configuration entities.

Hierarchy

Expanded class hierarchy of ConfigEntityListBuilder

Related topics

19 files declare their use of ConfigEntityListBuilder
BlockContentTypeListBuilder.php in core/modules/block_content/src/BlockContentTypeListBuilder.php
BlockListBuilder.php in core/modules/block/src/BlockListBuilder.php
CommentTypeListBuilder.php in core/modules/comment/src/CommentTypeListBuilder.php
ConfigQueryTest.php in core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php
ConfigTestListBuilder.php in core/modules/config/tests/config_test/src/ConfigTestListBuilder.php

... See full list

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php, line 14

Namespace

Drupal\Core\Config\Entity
View source
class ConfigEntityListBuilder extends EntityListBuilder {
  
  /**
   * The config entity storage class.
   *
   * @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface
   */
  protected $storage;
  
  /**
   * {@inheritdoc}
   */
  public function load() {
    $entity_ids = $this->getEntityIds();
    $entities = $this->storage
      ->loadMultipleOverrideFree($entity_ids);
    // Sort the entities using the entity class's sort() method.
    // See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
    uasort($entities, [
      $this->entityType
        ->getClass(),
      'sort',
    ]);
    return $entities;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getDefaultOperations(EntityInterface $entity) {
    $args = func_get_args();
    $cacheability = $args[1] ?? new CacheableMetadata();
    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
    $operations = parent::getDefaultOperations($entity, $cacheability);
    if ($this->entityType
      ->hasKey('status')) {
      if (!$entity->status() && $entity->hasLinkTemplate('enable')) {
        $operations['enable'] = [
          'title' => $this->t('Enable'),
          'weight' => -10,
          'url' => $this->ensureDestination($entity->toUrl('enable')),
        ];
      }
      elseif ($entity->hasLinkTemplate('disable')) {
        $operations['disable'] = [
          'title' => $this->t('Disable'),
          'weight' => 40,
          'url' => $this->ensureDestination($entity->toUrl('disable')),
        ];
      }
    }
    return $operations;
  }
  
  /**
   * Gets the config entity storage.
   *
   * @return \Drupal\Core\Config\Entity\ConfigEntityStorageInterface
   *   The config storage used by this list builder.
   */
  public function getStorage() : ConfigEntityStorageInterface {
    return $this->storage;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.