Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

ImageStyleListBuilder.php

Namespace

Drupal\image

File

core/modules/image/src/ImageStyleListBuilder.php

View source
<?php

namespace Drupal\image;

use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;

/**
 * Defines a class to build a listing of image style entities.
 *
 * @see \Drupal\image\Entity\ImageStyle
 */
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' => $this->t('Flush'),
            'weight' => 200,
            'url' => $entity->toUrl('flush-form'),
        ];
        return parent::getDefaultOperations($entity) + [
            'flush' => $flush,
        ];
    }
    
    /**
     * {@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;
    }

}

Classes

Title Deprecated Summary
ImageStyleListBuilder Defines a class to build a listing of image style entities.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal