class ImageStyleListBuilder

Same name and namespace in other branches
  1. 11.x core/modules/image/src/ImageStyleListBuilder.php \Drupal\image\ImageStyleListBuilder
  2. 10 core/modules/image/src/ImageStyleListBuilder.php \Drupal\image\ImageStyleListBuilder
  3. 8.9.x core/modules/image/src/ImageStyleListBuilder.php \Drupal\image\ImageStyleListBuilder

Defines a class to build a listing of image style entities.

Hierarchy

Expanded class hierarchy of ImageStyleListBuilder

See also

\Drupal\image\Entity\ImageStyle

File

core/modules/image/src/ImageStyleListBuilder.php, line 14

Namespace

Drupal\image
View source
class ImageStyleListBuilder extends ConfigEntityListBuilder {
  
  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['label'] = $this->t('Style name');
    return $header + parent::buildHeader();
  }
  
  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $entity->label();
    return $row + parent::buildRow($entity);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getDefaultOperations(EntityInterface $entity) {
    $flush = [
      'title' => t('Flush'),
      'weight' => 200,
      'url' => $entity->toUrl('flush-form'),
    ];
    $operations = parent::getDefaultOperations($entity) + [
      'flush' => $flush,
    ];
    // Remove destination URL from the edit link to allow editing image
    // effects.
    if (isset($operations['edit'])) {
      $operations['edit']['url'] = $entity->toUrl('edit-form');
    }
    return $operations;
  }
  
  /**
   * {@inheritdoc}
   */
  public function render() {
    $build = parent::render();
    $build['table']['#empty'] = $this->t('There are currently no styles. <a href=":url">Add a new one</a>.', [
      ':url' => Url::fromRoute('image.style_add')->toString(),
    ]);
    return $build;
  }

}

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