comparison core/modules/image/src/ImageStyleListBuilder.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children 12f9dff5fda9
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\image;
4
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Url;
8
9 /**
10 * Defines a class to build a listing of image style entities.
11 *
12 * @see \Drupal\image\Entity\ImageStyle
13 */
14 class ImageStyleListBuilder extends ConfigEntityListBuilder {
15
16 /**
17 * {@inheritdoc}
18 */
19 public function buildHeader() {
20 $header['label'] = $this->t('Style name');
21 return $header + parent::buildHeader();
22 }
23
24 /**
25 * {@inheritdoc}
26 */
27 public function buildRow(EntityInterface $entity) {
28 $row['label'] = $entity->label();
29 return $row + parent::buildRow($entity);
30 }
31
32 /**
33 * {@inheritdoc}
34 */
35 public function getDefaultOperations(EntityInterface $entity) {
36 $flush = [
37 'title' => t('Flush'),
38 'weight' => 200,
39 'url' => $entity->urlInfo('flush-form'),
40 ];
41
42 $operations = parent::getDefaultOperations($entity) + [
43 'flush' => $flush,
44 ];
45
46 // Remove destination URL from the edit link to allow editing image
47 // effects.
48 if (isset($operations['edit'])) {
49 $operations['edit']['url'] = $entity->toUrl('edit-form');
50 }
51
52 return $operations;
53 }
54
55 /**
56 * {@inheritdoc}
57 */
58 public function render() {
59 $build = parent::render();
60 $build['table']['#empty'] = $this->t('There are currently no styles. <a href=":url">Add a new one</a>.', [
61 ':url' => Url::fromRoute('image.style_add')->toString(),
62 ]);
63 return $build;
64 }
65
66 }