Mercurial > hg > isophonics-drupal-site
comparison core/modules/image/src/ImageStyleListBuilder.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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 return parent::getDefaultOperations($entity) + [ | |
43 'flush' => $flush, | |
44 ]; | |
45 } | |
46 | |
47 /** | |
48 * {@inheritdoc} | |
49 */ | |
50 public function render() { | |
51 $build = parent::render(); | |
52 $build['table']['#empty'] = $this->t('There are currently no styles. <a href=":url">Add a new one</a>.', [ | |
53 ':url' => Url::fromRoute('image.style_add')->toString(), | |
54 ]); | |
55 return $build; | |
56 } | |
57 | |
58 } |