diff --git a/core/lib/Drupal/Core/Entity/EntityListControllerBase.php b/core/lib/Drupal/Core/Entity/EntityListControllerBase.php
index 8d98df2..e251dcb 100644
--- a/core/lib/Drupal/Core/Entity/EntityListControllerBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityListControllerBase.php
@@ -82,9 +82,12 @@ public function buildRow(EntityInterface $entity) {
* Implements Drupal\Core\Entity\EntityListControllerInterface::buildOperations();
*/
public function buildOperations(EntityInterface $entity) {
+ // Retrieve and sort operations.
+ $operations = $this->getOperations($entity);
+ uasort($operations, 'drupal_sort_weight');
$build = array(
'#theme' => 'links',
- '#links' => $this->getOperations($entity),
+ '#links' => $operations,
);
return $build;
}
@@ -97,6 +100,10 @@ public function render() {
'#theme' => 'table',
'#header' => $this->buildHeader(),
'#rows' => array(),
+ '#empty' => t('There is no @label yet. Add one.', array(
+ '@label' => $this->entityInfo['label'],
+ '@add-url' => $this->getPath() . '/add',
+ )),
'#attributes' => array(
'id' => 'config-entity-listing',
),
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestListController.php b/core/modules/config/lib/Drupal/config/ConfigEntityListController.php
similarity index 75%
rename from core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestListController.php
rename to core/modules/config/lib/Drupal/config/ConfigEntityListController.php
index 58d9e5f..a674020 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestListController.php
+++ b/core/modules/config/lib/Drupal/config/ConfigEntityListController.php
@@ -2,23 +2,21 @@
/**
* @file
- * Definition of Drupal\config_test\ConfigTestListController.
+ * Definition of Drupal\config\ConfigEntityListController.
*/
-namespace Drupal\config_test;
+namespace Drupal\config;
use Drupal\Core\Entity\EntityListControllerBase;
use Drupal\Core\Entity\EntityInterface;
/**
- * Defines the list controller for ConfigTest entities.
+ * Default list controller for ConfigEntity objects.
*/
-class ConfigTestListController extends EntityListControllerBase {
+class ConfigEntityListController extends EntityListControllerBase {
/**
* Overrides Drupal\Core\Entity\EntityListControllerBase::load().
- *
- * @todo Move into a generic ConfigEntityListControllerBase?
*/
public function load() {
$entities = parent::load();
@@ -35,11 +33,13 @@ public function getOperations(EntityInterface $entity) {
'title' => t('edit'),
'href' => $uri['path'] . '/edit',
'options' => $uri['options'],
+ 'weight' => 10,
);
$operations['delete'] = array(
'title' => t('delete'),
'href' => $uri['path'] . '/delete',
'options' => $uri['options'],
+ 'weight' => 100,
);
return $operations;
}
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
index 5379430..46d52f6 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
@@ -36,11 +36,11 @@ public static function getInfo() {
function testList() {
$controller = entity_list_controller('config_test');
- // Get a list of Config entities.
- $list = $controller->getList();
- $this->assertEqual(count($list), 1, 'Correct number of plugins found.');
- $this->assertTrue(!empty($list['default']), '"Default" config entity key found in list.');
- $this->assertTrue($list['default'] instanceof ConfigTest, '"Default" config entity is an instance of ConfigTest.');
+ // Get a list of ConfigTest entities.
+ $list = $controller->load();
+ $this->assertEqual(count($list), 1, '1 ConfigTest entity found.');
+ $this->assertTrue(!empty($list['default']), '"Default" ConfigTest entity ID found.');
+ $this->assertTrue($list['default'] instanceof ConfigTest, '"Default" ConfigTest entity is an instance of ConfigTest.');
}
/**
@@ -48,16 +48,14 @@ function testList() {
*/
function testListUI() {
$page = $this->drupalGet('admin/structure/config_test');
+ $this->assertText('Test configuration');
- // Test that the page exists.
- $this->assertText('Config test', 'Config test listing page title found.');
+ // Verify that the default ConfigTest configuration appears.
+ $this->assertText('default');
+ $this->assertText('Default');
- // Check we have the default id and label on the page too.
- $this->assertText('default', '"default" ID found.');
- $this->assertText('Default', '"Default" label found');
-
- // Check each link.
- foreach (array('edit', 'add', 'delete') as $link) {
+ // Verify that operation links appear.
+ foreach (array('edit', 'delete') as $link) {
$this->drupalSetContent($page);
$this->assertLink($link);
$this->clickLink($link);
diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module
index 25bb89d..a75eff8 100644
--- a/core/modules/config/tests/config_test/config_test.module
+++ b/core/modules/config/tests/config_test/config_test.module
@@ -82,7 +82,7 @@ function config_test_entity_info() {
'label' => 'Test configuration',
'controller class' => 'Drupal\config\ConfigStorageController',
'entity class' => 'Drupal\config_test\ConfigTest',
- 'list controller class' => 'Drupal\config_test\ConfigTestListController',
+ 'list controller class' => 'Drupal\config\ConfigEntityListController',
'list path' => 'admin/structure/config_test',
'uri callback' => 'config_test_uri',
'config prefix' => 'config_test.dynamic',
@@ -205,9 +205,6 @@ function config_test_list_page() {
'#theme' => 'table',
'#header' => array('Name', 'Operations'),
'#rows' => $rows,
- '#empty' => format_string('No test configuration defined. Add some', array(
- '@add-url' => url('admin/structure/config_test/add'),
- )),
);
return $build;
}