summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-08-28 22:11:52 +0100
committerNathaniel Catchpole2016-08-29 07:59:35 +0100
commit28a7bb1a98718efc7059eb32f852ed8541447ba6 (patch)
tree6d6b221be6590fb6aad592fc7380590691756dce
parenta46d123bc708f8254562aa56d6ca49c1d17a6bcb (diff)
Issue #2490290 by willzyx, Mile23, alexpott, tim.plunkett: Subclasses of EntityListBuilder incorrectly override the #empty message
(cherry picked from commit f37eba61fcfa6cb5cf1795a32d7415e486b4a7d6)
-rw-r--r--core/modules/action/src/ActionListBuilder.php4
-rw-r--r--core/modules/action/src/Tests/ActionListTest.php37
-rw-r--r--core/modules/image/src/ImageStyleListBuilder.php41
3 files changed, 41 insertions, 41 deletions
diff --git a/core/modules/action/src/ActionListBuilder.php b/core/modules/action/src/ActionListBuilder.php
index 0902403..0a54cd6 100644
--- a/core/modules/action/src/ActionListBuilder.php
+++ b/core/modules/action/src/ActionListBuilder.php
@@ -108,10 +108,10 @@ class ActionListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function render() {
- $build['action_header']['#markup'] = '<h3>' . t('Available actions:') . '</h3>';
+ $build['action_header']['#markup'] = '<h3>' . $this->t('Available actions:') . '</h3>';
$build['action_table'] = parent::render();
if (!$this->hasConfigurableActions) {
- unset($build['action_table']['#header']['operations']);
+ unset($build['action_table']['table']['#header']['operations']);
}
$build['action_admin_manage_form'] = \Drupal::formBuilder()->getForm('Drupal\action\Form\ActionAdminManageForm');
return $build;
diff --git a/core/modules/action/src/Tests/ActionListTest.php b/core/modules/action/src/Tests/ActionListTest.php
new file mode 100644
index 0000000..f533cdf
--- /dev/null
+++ b/core/modules/action/src/Tests/ActionListTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Drupal\action\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test behaviors when visiting the action listing page.
+ *
+ * @group action
+ */
+class ActionListTest extends WebTestBase {
+
+ /**
+ * Modules to install.
+ *
+ * @var array
+ */
+ public static $modules = array('action');
+
+ /**
+ * Tests the behavior when there are no actions to list in the admin page.
+ */
+ public function testEmptyActionList() {
+ // Create a user with permission to view the actions administration pages.
+ $this->drupalLogin($this->drupalCreateUser(['administer actions']));
+
+ // Ensure the empty text appears on the action list page.
+ /** @var $storage \Drupal\Core\Entity\EntityStorageInterface */
+ $storage = $this->container->get('entity.manager')->getStorage('action');
+ $actions = $storage->loadMultiple();
+ $storage->delete($actions);
+ $this->drupalGet('/admin/config/system/actions');
+ $this->assertRaw('There is no Action yet.');
+ }
+
+}
diff --git a/core/modules/image/src/ImageStyleListBuilder.php b/core/modules/image/src/ImageStyleListBuilder.php
index e4e0be6..140ed46 100644
--- a/core/modules/image/src/ImageStyleListBuilder.php
+++ b/core/modules/image/src/ImageStyleListBuilder.php
@@ -4,10 +4,7 @@ namespace Drupal\image;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityStorageInterface;
-use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Core\Routing\UrlGeneratorInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Core\Url;
/**
* Defines a class to build a listing of image style entities.
@@ -17,40 +14,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class ImageStyleListBuilder extends ConfigEntityListBuilder {
/**
- * The URL generator.
- *
- * @var \Drupal\Core\Routing\UrlGeneratorInterface
- */
- protected $urlGenerator;
-
- /**
- * Constructs a new ImageStyleListBuilder object.
- *
- * @param EntityTypeInterface $entity_type
- * The entity type definition.
- * @param \Drupal\Core\Entity\EntityStorageInterface $image_style_storage
- * The image style entity storage class.
- * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
- * The URL generator.
- */
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $image_style_storage, UrlGeneratorInterface $url_generator) {
- parent::__construct($entity_type, $image_style_storage);
- $this->urlGenerator = $url_generator;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
- return new static(
- $entity_type,
- $container->get('entity.manager')->getStorage($entity_type->id()),
- $container->get('url_generator'),
- $container->get('string_translation')
- );
- }
-
- /**
* {@inheritdoc}
*/
public function buildHeader() {
@@ -87,7 +50,7 @@ class ImageStyleListBuilder extends ConfigEntityListBuilder {
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' => $this->urlGenerator->generateFromRoute('image.style_add'),
+ ':url' => Url::fromRoute('image.style_add')->toString(),
]);
return $build;
}