Mercurial > hg > isophonics-drupal-site
annotate 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 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\image; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder; |
Chris@0 | 6 use Drupal\Core\Entity\EntityInterface; |
Chris@0 | 7 use Drupal\Core\Url; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Defines a class to build a listing of image style entities. |
Chris@0 | 11 * |
Chris@0 | 12 * @see \Drupal\image\Entity\ImageStyle |
Chris@0 | 13 */ |
Chris@0 | 14 class ImageStyleListBuilder extends ConfigEntityListBuilder { |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * {@inheritdoc} |
Chris@0 | 18 */ |
Chris@0 | 19 public function buildHeader() { |
Chris@0 | 20 $header['label'] = $this->t('Style name'); |
Chris@0 | 21 return $header + parent::buildHeader(); |
Chris@0 | 22 } |
Chris@0 | 23 |
Chris@0 | 24 /** |
Chris@0 | 25 * {@inheritdoc} |
Chris@0 | 26 */ |
Chris@0 | 27 public function buildRow(EntityInterface $entity) { |
Chris@0 | 28 $row['label'] = $entity->label(); |
Chris@0 | 29 return $row + parent::buildRow($entity); |
Chris@0 | 30 } |
Chris@0 | 31 |
Chris@0 | 32 /** |
Chris@0 | 33 * {@inheritdoc} |
Chris@0 | 34 */ |
Chris@0 | 35 public function getDefaultOperations(EntityInterface $entity) { |
Chris@0 | 36 $flush = [ |
Chris@0 | 37 'title' => t('Flush'), |
Chris@0 | 38 'weight' => 200, |
Chris@0 | 39 'url' => $entity->urlInfo('flush-form'), |
Chris@0 | 40 ]; |
Chris@0 | 41 |
Chris@0 | 42 return parent::getDefaultOperations($entity) + [ |
Chris@0 | 43 'flush' => $flush, |
Chris@0 | 44 ]; |
Chris@0 | 45 } |
Chris@0 | 46 |
Chris@0 | 47 /** |
Chris@0 | 48 * {@inheritdoc} |
Chris@0 | 49 */ |
Chris@0 | 50 public function render() { |
Chris@0 | 51 $build = parent::render(); |
Chris@0 | 52 $build['table']['#empty'] = $this->t('There are currently no styles. <a href=":url">Add a new one</a>.', [ |
Chris@0 | 53 ':url' => Url::fromRoute('image.style_add')->toString(), |
Chris@0 | 54 ]); |
Chris@0 | 55 return $build; |
Chris@0 | 56 } |
Chris@0 | 57 |
Chris@0 | 58 } |