diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/image/src/ImageStyleListBuilder.php	Wed Nov 29 16:09:58 2017 +0000
@@ -0,0 +1,58 @@
+<?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' => t('Flush'),
+      'weight' => 200,
+      'url' => $entity->urlInfo('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;
+  }
+
+}