diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php index 4ef6911978403f77734b2c94cb77db930b4d964b..c4fa043a42346a781564ee2039d1cf5aab05692a 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php @@ -31,21 +31,23 @@ public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); $uri = $entity->uri(); - if (!$entity->status()) { - $operations['enable'] = array( - 'title' => t('Enable'), - 'href' => $uri['path'] . '/enable', - 'options' => $uri['options'], - 'weight' => -10, - ); - } - else { - $operations['disable'] = array( - 'title' => t('Disable'), - 'href' => $uri['path'] . '/disable', - 'options' => $uri['options'], - 'weight' => 20, - ); + if (isset($this->entityInfo['entity_keys']['status'])) { + if (!$entity->status()) { + $operations['enable'] = array( + 'title' => t('Enable'), + 'href' => $uri['path'] . '/enable', + 'options' => $uri['options'], + 'weight' => -10, + ); + } + else { + $operations['disable'] = array( + 'title' => t('Disable'), + 'href' => $uri['path'] . '/disable', + 'options' => $uri['options'], + 'weight' => 20, + ); + } } 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 f851cbc2500a6786c195b5cc52837428db5d509c..b67cb4a20504e3a9937ef0696830b3e1ddec9878 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -98,6 +98,36 @@ function testList() { ); $actual_items = $controller->buildRow($entity); $this->assertIdentical($expected_items, $actual_items, 'Return value from buildRow matches expected.'); + + // Test that config entities that do not support status, do not have + // enable/disable operations. + $controller = $this->container->get('plugin.manager.entity') + ->getListController('config_test_no_status'); + + $list = $controller->load(); + $entity = $list['default']; + + // Test getOperations() method. + $uri = $entity->uri(); + $expected_operations = array( + 'edit' => array( + 'title' => t('Edit'), + 'href' => $uri['path'] . '/edit', + 'options' => $uri['options'], + 'weight' => 10, + ), + 'delete' => array( + 'title' => t('Delete'), + 'href' => $uri['path'] . '/delete', + 'options' => $uri['options'], + 'weight' => 100, + ), + ); + + $actual_operations = $controller->getOperations($entity); + // Sort the operations to normalize link order. + uasort($actual_operations, 'drupal_sort_weight'); + $this->assertIdentical($expected_operations, $actual_operations); } /** diff --git a/core/modules/config/tests/config_test/config/config_test.no_status.default.yml b/core/modules/config/tests/config_test/config/config_test.no_status.default.yml new file mode 100644 index 0000000000000000000000000000000000000000..3e50e3bbd3de64665a873daf098a59326e0cefba --- /dev/null +++ b/core/modules/config/tests/config_test/config/config_test.no_status.default.yml @@ -0,0 +1,2 @@ +id: default +label: Default diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index c2c004c121e10bf0a15b24540f92ba481b1c6904..9949d90e595bcfe9e01efde61da23f9a38ffee43 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -181,4 +181,9 @@ function config_test_entity_info_alter(&$entity_info) { // case we can safely do it because we set it once and we do not change it for // all the duration of the test session. $entity_info['config_test']['translatable'] = Drupal::service('state')->get('config_test.translatable'); + + // Create a clone of config_test that does not have a status. + $entity_info['config_test_no_status'] = $entity_info['config_test']; + unset($entity_info['config_test_no_status']['entity_keys']['status']); + $entity_info['config_test_no_status']['config_prefix'] = 'config_test.no_status'; } diff --git a/core/modules/user/lib/Drupal/user/RoleListController.php b/core/modules/user/lib/Drupal/user/RoleListController.php index 177b2d67cf1b1f6eacae1c3c098c8556aafd5d0d..9ff5c8353e3d2a409b15a8e29ca6568c93682b72 100644 --- a/core/modules/user/lib/Drupal/user/RoleListController.php +++ b/core/modules/user/lib/Drupal/user/RoleListController.php @@ -48,7 +48,6 @@ public function getOperations(EntityInterface $entity) { // Built-in roles could not be deleted or disabled. if (in_array($entity->id(), array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { unset($operations['delete']); - unset($operations['disable']); } return $operations; }