ImageStyleListBuilder.php in Drupal 9
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;
class ImageStyleListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['label'] = $this
->t('Style name');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$flush = [
'title' => t('Flush'),
'weight' => 200,
'url' => $entity
->toUrl('flush-form'),
];
$operations = parent::getDefaultOperations($entity) + [
'flush' => $flush,
];
if (isset($operations['edit'])) {
$operations['edit']['url'] = $entity
->toUrl('edit-form');
}
return $operations;
}
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;
}
}