diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 490470d..21f7716 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -27,6 +27,13 @@ protected $originalID; /** + * The enabled/disabled status of the configuration entity. + * + * @var bool + */ + public $status; + + /** * Overrides Entity::__construct(). */ public function __construct(array $values, $entity_type) { @@ -89,6 +96,29 @@ public function set($property_name, $value, $langcode = NULL) { } /** + * Implements Drupal\Core\Config\Entity\ConfigEntityInterface::enable(). + */ + public function enable() { + $this->status = TRUE; + return $this; + } + + /** + * Implements Drupal\Core\Config\Entity\ConfigEntityInterface::disable(). + */ + public function disable() { + $this->status = FALSE; + return $this; + } + + /** + * Implements Drupal\Core\Config\Entity\ConfigEntityInterface::status(). + */ + public function status() { + return !empty($this->status); + } + + /** * Overrides Entity::createDuplicate(). */ public function createDuplicate() { diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index 15ef4dd..8df5847 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -32,4 +32,27 @@ public function getOriginalID(); */ public function setOriginalID($id); + /** + * Enables the configuration entity. + * + * @return \Drupal\Core\Config\Entity\ConfigEntityInterface + * The configuration entity. + */ + public function enable(); + + /** + * Disables the configuration entity. + * + * @return \Drupal\Core\Config\Entity\ConfigEntityInterface + * The configuration entity. + */ + public function disable(); + + /** + * Returns whether the configuration entity is enabled. + * + * @return bool + */ + public function status(); + } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php index 3977310..c2e204b 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Config\Entity; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListController; /** @@ -23,4 +24,31 @@ public function load() { return $entities; } + /** + * Overrides Drupal\Core\Entity\EntityListController::getOperations(); + */ + 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, + ); + } + + return $operations; + } + } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index b472b8f..b98934b 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -58,6 +58,13 @@ class ConfigStorageController implements EntityStorageControllerInterface { protected $uuidKey = 'uuid'; /** + * Name of the entity's status key or FALSE if a status is not supported. + * + * @var string|bool + */ + protected $statusKey = 'status'; + + /** * Implements Drupal\Core\Entity\EntityStorageControllerInterface::__construct(). * * Sets basic variables. @@ -67,6 +74,13 @@ public function __construct($entityType) { $this->entityInfo = entity_get_info($entityType); $this->hookLoadArguments = array(); $this->idKey = $this->entityInfo['entity_keys']['id']; + + if (isset($this->entityInfo['entity_keys']['status'])) { + $this->statusKey = $this->entityInfo['entity_keys']['status']; + } + else { + $this->statusKey = FALSE; + } } /** @@ -244,6 +258,11 @@ public function create(array $values) { $entity->{$this->uuidKey} = $uuid->generate(); } + // Default status to enabled. + if (!empty($this->statusKey) && !isset($entity->{$this->statusKey})) { + $entity->{$this->statusKey} = TRUE; + } + return $entity; } diff --git a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml index 4dca1cd..a6b4f11 100644 --- a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml +++ b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index 13f5a76..2a6bb85 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -53,20 +53,29 @@ function testList() { $uri = $entity->uri(); $expected_operations = array( 'edit' => array ( - 'title' => 'Edit', - 'href' => 'admin/structure/config_test/manage/default/edit', + 'title' => t('Edit'), + 'href' => $uri['path'] . '/edit', 'options' => $uri['options'], 'weight' => 10, ), + 'disable' => array( + 'title' => t('Disable'), + 'href' => $uri['path'] . '/disable', + 'options' => $uri['options'], + 'weight' => 20, + ), 'delete' => array ( - 'title' => 'Delete', - 'href' => 'admin/structure/config_test/manage/default/delete', + 'title' => t('Delete'), + 'href' => $uri['path'] . '/delete', 'options' => $uri['options'], 'weight' => 100, ), ); + $actual_operations = $controller->getOperations($entity); - $this->assertIdentical($expected_operations, $actual_operations, 'Return value from getOperations matches expected.'); + // Sort the operations to normalize link order. + uasort($actual_operations, 'drupal_sort_weight'); + $this->assertIdentical($expected_operations, $actual_operations); // Test buildHeader() method. $expected_items = array( diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityStatusTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityStatusTest.php new file mode 100644 index 0000000..110b57c --- /dev/null +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityStatusTest.php @@ -0,0 +1,54 @@ + 'Configuration entity status', + 'description' => 'Tests configuration entity status functionality.', + 'group' => 'Configuration', + ); + } + + /** + * Test the enabling/disabling of entities. + */ + function testCRUD() { + $entity = entity_create('config_test', array( + 'id' => strtolower($this->randomName()), + )); + $this->assertTrue($entity->status(), 'Default status is enabled.'); + $entity->save(); + $this->assertTrue($entity->status(), 'Status is enabled after saving.'); + + $entity->disable()->save(); + $this->assertFalse($entity->status(), 'Entity is disabled after disabling.'); + + $entity->enable()->save(); + $this->assertTrue($entity->status(), 'Entity is enabled after enabling.'); + + $entity = entity_load('config_test', $entity->id()); + $this->assertTrue($entity->status(), 'Status is enabled after reload.'); + } + +} diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityStatusUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityStatusUITest.php new file mode 100644 index 0000000..036f6bf --- /dev/null +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityStatusUITest.php @@ -0,0 +1,59 @@ + 'Configuration entity status UI', + 'description' => 'Tests configuration entity status UI functionality.', + 'group' => 'Configuration', + ); + } + + /** + * Tests status operations. + */ + function testCRUD() { + $id = strtolower($this->randomName()); + $edit = array( + 'id' => $id, + 'label' => $this->randomName(), + ); + $this->drupalPost('admin/structure/config_test/add', $edit, 'Save'); + + // Disable an entity. + $disable_path = "admin/structure/config_test/manage/$id/disable"; + $this->assertLinkByHref($disable_path); + $this->drupalGet($disable_path); + $this->assertResponse(200); + $this->assertNoLinkByHref($disable_path); + + // Enable an entity. + $enable_path = "admin/structure/config_test/manage/$id/enable"; + $this->assertLinkByHref($enable_path); + $this->drupalGet($enable_path); + $this->assertResponse(200); + $this->assertNoLinkByHref($enable_path); + } + +} diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php index 95089f7..a939830 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php @@ -107,6 +107,7 @@ function testNew() { 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'label' => 'New', 'style' => '', + 'status' => '1', 'langcode' => 'und', ); $staging->write($dynamic_name, $original_dynamic_data); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index dd24224..3417eb2 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -59,6 +59,7 @@ function testImport() { 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'label' => 'New', 'style' => '', + 'status' => '1', 'langcode' => 'und', ); $staging->write($dynamic_name, $original_dynamic_data); diff --git a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml b/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml index 3e50e3b..45cb29e 100644 --- a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml +++ b/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml @@ -1,2 +1,4 @@ id: default label: Default +# Intentionally commented out to verify default status behavior. +# status: 1 diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 5dbcb92..599d452 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -6,6 +6,7 @@ */ use Drupal\config_test\Plugin\Core\Entity\ConfigTest; +use Symfony\Component\HttpFoundation\RedirectResponse; require_once dirname(__FILE__) . '/config_test.hooks.inc'; @@ -54,6 +55,18 @@ function config_test_menu() { 'access callback' => TRUE, 'type' => MENU_LOCAL_TASK, ); + $items['admin/structure/config_test/manage/%config_test/enable'] = array( + 'title' => 'Enable', + 'page callback' => 'config_test_entity_enable', + 'page arguments' => array(4), + 'access callback' => TRUE, + ); + $items['admin/structure/config_test/manage/%config_test/disable'] = array( + 'title' => 'Disable', + 'page callback' => 'config_test_entity_disable', + 'page arguments' => array(4), + 'access callback' => TRUE, + ); return $items; } @@ -136,3 +149,28 @@ function config_test_cache_flush() { return array(); } + +/** + * Enables a ConfigTest object. + * + * @param Drupal\config_test\ConfigTest $config_test + * The ConfigTest object to enable. + */ +function config_test_entity_enable(ConfigTest $config_test) { + $config_test->enable(); + $config_test->save(); + return new RedirectResponse(url('admin/structure/config_test', array('absolute' => TRUE))); +} + +/** + * Disables a ConfigTest object. + * + * @param Drupal\config_test\ConfigTest $config_test + * The ConfigTest object to disable. + */ +function config_test_entity_disable(ConfigTest $config_test) { + $config_test->disable(); + $config_test->save(); + return new RedirectResponse(url('admin/structure/config_test', array('absolute' => TRUE))); +} + diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php index 52da777..c3d04ca 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php @@ -28,7 +28,8 @@ * entity_keys = { * "id" = "id", * "label" = "label", - * "uuid" = "uuid" + * "uuid" = "uuid", + * "status" = "status" * } * ) */ diff --git a/core/modules/field/tests/modules/field_test_views/test_views/views.view.test_view_fieldapi.yml b/core/modules/field/tests/modules/field_test_views/test_views/views.view.test_view_fieldapi.yml index fe2ecc0..17d25fe 100644 --- a/core/modules/field/tests/modules/field_test_views/test_views/views.view.test_view_fieldapi.yml +++ b/core/modules/field/tests/modules/field_test_views/test_views/views.view.test_view_fieldapi.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/StatusExtraTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/StatusExtraTest.php index ecd09b5..a7f2ea6 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/StatusExtraTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/StatusExtraTest.php @@ -35,7 +35,8 @@ public static function getInfo() { public function testStatusExtra() { // @todo For whatever reason the menu has to be rebuilt or drupalGet will // fail. - state()->set('menu_rebuild_needed', TRUE); + menu_router_rebuild(); + $column_map = array('nid' => 'nid'); $node_author = $this->drupalCreateUser(array('view own unpublished content')); $node_author_not_unpublished = $this->drupalCreateUser(); diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_type.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_type.yml index c9172bc..d137c70 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_type.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_type.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_filter_node_uid_revision.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_filter_node_uid_revision.yml index 69000ec..303b3cf 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_filter_node_uid_revision.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_filter_node_uid_revision.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: 8.0-dev description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml index 5240f0c..bc8da18 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml @@ -3,7 +3,7 @@ base_field: tid base_table: taxonomy_term_data core: 8.0-dev description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_node_term_data.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_node_term_data.yml index 383766a..e558bcf 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_node_term_data.yml +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_node_term_data.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_access_perm.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_access_perm.yml index f509323..38bf63d 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_access_perm.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_access_perm.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_access_role.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_access_role.yml index 3d2b4d9..90c24eb 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_access_role.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_access_role.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_groupwise_user.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_groupwise_user.yml index 7d79d11..5d107d4 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_groupwise_user.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_groupwise_user.yml @@ -3,7 +3,7 @@ base_field: uid base_table: users core: 8.0-dev description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml index 54180b6..be3332c 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_user_name.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_user_name.yml index ab243bc..a8dbfb8 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_user_name.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_user_name.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: users core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_user_relationship.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_user_relationship.yml index 096fa16..7262ff0 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_user_relationship.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_user_relationship.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_user_uid_argument.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_user_uid_argument.yml index 7dfce3e..03a5c54 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_user_uid_argument.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_user_uid_argument.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: users core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_view_argument_validate_user.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_view_argument_validate_user.yml index 2750f43..b84b4ed 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_view_argument_validate_user.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_view_argument_validate_user.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/user/tests/user_test_views/test_views/views.view.test_views_handler_field_user_name.yml b/core/modules/user/tests/user_test_views/test_views/views.view.test_views_handler_field_user_name.yml index 48522e0..9bec009 100644 --- a/core/modules/user/tests/user_test_views/test_views/views.view.test_views_handler_field_user_name.yml +++ b/core/modules/user/tests/user_test_views/test_views/views.view.test_views_handler_field_user_name.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: users core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/config/views.view.archive.yml b/core/modules/views/config/views.view.archive.yml index f018c57..79e32d0 100644 --- a/core/modules/views/config/views.view.archive.yml +++ b/core/modules/views/config/views.view.archive.yml @@ -1,4 +1,4 @@ -disabled: true +status: '0' api_version: '3.0' module: node name: archive diff --git a/core/modules/views/config/views.view.backlinks.yml b/core/modules/views/config/views.view.backlinks.yml index 3d9011b..f8df032 100644 --- a/core/modules/views/config/views.view.backlinks.yml +++ b/core/modules/views/config/views.view.backlinks.yml @@ -1,4 +1,4 @@ -disabled: true +status: '0' api_version: '3.0' module: search name: backlinks diff --git a/core/modules/views/config/views.view.comments_recent.yml b/core/modules/views/config/views.view.comments_recent.yml index 336f0da..17bb8c0 100644 --- a/core/modules/views/config/views.view.comments_recent.yml +++ b/core/modules/views/config/views.view.comments_recent.yml @@ -1,4 +1,4 @@ -disabled: true +status: '0' api_version: '3.0' module: comment name: comments_recent diff --git a/core/modules/views/config/views.view.frontpage.yml b/core/modules/views/config/views.view.frontpage.yml index a635a0e..8feb942 100644 --- a/core/modules/views/config/views.view.frontpage.yml +++ b/core/modules/views/config/views.view.frontpage.yml @@ -1,4 +1,4 @@ -disabled: true +status: '0' api_version: '3.0' module: node name: frontpage diff --git a/core/modules/views/config/views.view.glossary.yml b/core/modules/views/config/views.view.glossary.yml index 18f059c..038e946 100644 --- a/core/modules/views/config/views.view.glossary.yml +++ b/core/modules/views/config/views.view.glossary.yml @@ -1,4 +1,4 @@ -disabled: true +status: '0' api_version: '3.0' module: node name: glossary diff --git a/core/modules/views/config/views.view.taxonomy_term.yml b/core/modules/views/config/views.view.taxonomy_term.yml index 40d85ed..0da8330 100644 --- a/core/modules/views/config/views.view.taxonomy_term.yml +++ b/core/modules/views/config/views.view.taxonomy_term.yml @@ -1,4 +1,4 @@ -disabled: true +status: '0' api_version: '3.0' module: taxonomy name: taxonomy_term diff --git a/core/modules/views/config/views.view.tracker.yml b/core/modules/views/config/views.view.tracker.yml index e9c903d..326eb32 100644 --- a/core/modules/views/config/views.view.tracker.yml +++ b/core/modules/views/config/views.view.tracker.yml @@ -1,4 +1,4 @@ -disabled: true +status: '0' api_version: '3.0' module: node name: tracker diff --git a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php index 6837952..92fdcef 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php @@ -34,7 +34,8 @@ * entity_keys = { * "id" = "name", * "label" = "human_name", - * "uuid" = "uuid" + * "uuid" = "uuid", + * "status" = "status" * } * ) */ @@ -110,16 +111,6 @@ class View extends ConfigEntityBase implements ViewStorageInterface { protected $base_field = 'nid'; /** - * Returns whether the view's status is disabled or not. - * - * This value is used for exported view, to provide some default views which - * aren't enabled. - * - * @var bool - */ - protected $disabled = FALSE; - - /** * The UUID for this entity. * * @var string @@ -178,29 +169,6 @@ public function createDuplicate() { } /** - * Implements Drupal\views\ViewStorageInterface::enable(). - */ - public function enable() { - $this->disabled = FALSE; - $this->save(); - } - - /** - * Implements Drupal\views\ViewStorageInterface::disable(). - */ - public function disable() { - $this->disabled = TRUE; - $this->save(); - } - - /** - * Implements Drupal\views\ViewStorageInterface::isEnabled(). - */ - public function isEnabled() { - return !$this->disabled; - } - - /** * Return the human readable name for a view. * * When a certain view doesn't have a human readable name return the machine readable name. @@ -367,7 +335,7 @@ public function getPaths() { foreach ($this->display as $display) { if (!empty($display['display_options']['path'])) { $path = $display['display_options']['path']; - if ($this->isEnabled() && strpos($path, '%') === FALSE) { + if ($this->status() && strpos($path, '%') === FALSE) { $all_paths[] = l('/' . $path, $path); } else { @@ -390,7 +358,7 @@ public function getExportProperties() { 'base_table', 'core', 'description', - 'disabled', + 'status', 'display', 'human_name', 'module', diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php index 1bb7cfe..bd8a431 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php @@ -41,7 +41,7 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { // Check all Views for block displays. foreach (views_get_all_views() as $view) { // Do not return results for disabled views. - if (!$view->isEnabled()) { + if (!$view->status()) { continue; } $executable = $view->get('executable'); diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php index c537184..59e40ba 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php @@ -41,7 +41,7 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { // Check all Views for displays with an exposed filter block. foreach (views_get_all_views() as $view) { // Do not return results for disabled views. - if (!$view->isEnabled()) { + if (!$view->status()) { continue; } $executable = $view->get('executable'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php index 7d32690..e0bfe8a 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php @@ -173,7 +173,10 @@ public function testTitleArea() { ), )); - $view->storage->enable(); + $view->storage->enable()->save(); + + // Force the rebuild of the menu. + menu_router_rebuild(); $this->drupalGet('frontpage'); $this->assertText('Overridden title', 'Overridden title found.'); diff --git a/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php b/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php index 5ecedec..806ee64 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php @@ -178,19 +178,21 @@ public function testLoadFunctions() { /** * Tests view enable and disable procedural wrapper functions. + * + * @todo This test is obsolete; remove it. */ function testStatusFunctions() { $view = views_get_view('test_view_status')->storage; - $this->assertFalse($view->isEnabled(), 'The view status is disabled.'); + $this->assertFalse($view->status(), 'The view status is disabled.'); views_enable_view($view); - $this->assertTrue($view->isEnabled(), 'A view has been enabled.'); - $this->assertEqual($view->isEnabled(), views_view_is_enabled($view), 'views_view_is_enabled is correct.'); + $this->assertTrue($view->status(), 'A view has been enabled.'); + $this->assertEqual($view->status(), views_view_is_enabled($view), 'views_view_is_enabled is correct.'); views_disable_view($view); - $this->assertFalse($view->isEnabled(), 'A view has been disabled.'); - $this->assertEqual(!$view->isEnabled(), views_view_is_disabled($view), 'views_view_is_disabled is correct.'); + $this->assertFalse($view->status(), 'A view has been disabled.'); + $this->assertEqual(!$view->status(), views_view_is_disabled($view), 'views_view_is_disabled is correct.'); } /** diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php index e7ac8f0..784595b 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php @@ -27,7 +27,7 @@ class ViewStorageTest extends ViewTestBase { * @var array */ protected $config_properties = array( - 'disabled', + 'status', 'api_version', 'module', 'name', @@ -103,7 +103,7 @@ protected function loadTests() { // expected properties. $this->assertTrue($view instanceof View, 'Single View instance loaded.'); foreach ($this->config_properties as $property) { - $this->assertTrue($view->get($property), format_string('Property: @property loaded onto View.', array('@property' => $property))); + $this->assertTrue($view->get($property) !== NULL, format_string('Property: @property loaded onto View.', array('@property' => $property))); } // Check the displays have been loaded correctly from config display data. @@ -171,7 +171,7 @@ protected function createTests() { // Test all properties except displays. foreach ($properties as $property) { - $this->assertTrue($created->get($property), format_string('Property: @property created on View.', array('@property' => $property))); + $this->assertTrue($created->get($property) !== NULL, format_string('Property: @property created on View.', array('@property' => $property))); $this->assertIdentical($values[$property], $created->get($property), format_string('Property value: @property matches configuration value.', array('@property' => $property))); } @@ -207,6 +207,8 @@ protected function displayTests() { /** * Tests statuses of configuration entities. + * + * @todo This test is obsolete; remove it. */ protected function statusTests() { // Test a View can be enabled and disabled again (with a new view). @@ -214,21 +216,21 @@ protected function statusTests() { // The view should already be disabled. $view->enable(); - $this->assertTrue($view->isEnabled(), 'A view has been enabled.'); + $this->assertTrue($view->status(), 'A view has been enabled.'); // Check the saved values. $view->save(); $config = config('views.view.backlinks')->get(); - $this->assertFalse($config['disabled'], 'The changed disabled property was saved.'); + $this->assertTrue($config['status'], 'The changed status property was saved.'); // Disable the view. $view->disable(); - $this->assertFalse($view->isEnabled(), 'A view has been disabled.'); + $this->assertFalse($view->status(), 'A view has been disabled.'); // Check the saved values. $view->save(); $config = config('views.view.backlinks')->get(); - $this->assertTrue($config['disabled'], 'The changed disabled property was saved.'); + $this->assertFalse($config['status'], 'The changed disabled property was saved.'); } /** @@ -237,7 +239,7 @@ protected function statusTests() { * @param string $view_name * The machine name of the view. * - * @return object Drupal\views\ViewExecutable. + * @return \Drupal\views\Plugin\Core\Entity\View. * The loaded view object. */ protected function loadView($view_name) { diff --git a/core/modules/views/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php index a6a55a3..5ca3fa7 100644 --- a/core/modules/views/lib/Drupal/views/ViewExecutable.php +++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php @@ -1512,7 +1512,7 @@ public function executeHookMenu($display_id = NULL, &$callbacks = array()) { */ public function access($displays = NULL, $account = NULL) { // Noone should have access to disabled views. - if (!$this->storage->isEnabled()) { + if (!$this->storage->status()) { return FALSE; } diff --git a/core/modules/views/lib/Drupal/views/ViewStorageInterface.php b/core/modules/views/lib/Drupal/views/ViewStorageInterface.php index 01bb87d..9bd3ba5 100644 --- a/core/modules/views/lib/Drupal/views/ViewStorageInterface.php +++ b/core/modules/views/lib/Drupal/views/ViewStorageInterface.php @@ -13,22 +13,4 @@ * Defines an interface for View storage classes. */ interface ViewStorageInterface extends \IteratorAggregate, ConfigEntityInterface { - - /** - * Sets the configuration entity status to enabled. - */ - public function enable(); - - /** - * Sets the configuration entity status to disabled. - */ - public function disable(); - - /** - * Returns whether the configuration entity is enabled. - * - * @return bool - */ - public function isEnabled(); - } diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml b/core/modules/views/tests/views_test_config/config/views.view.test_views_move_to_field.yml similarity index 58% copy from core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml copy to core/modules/views/tests/views_test_config/config/views.view.test_views_move_to_field.yml index 6d0d73f..af2c47f 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_views_move_to_field.yml @@ -2,25 +2,19 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: - access: - type: none - cache: - type: none fields: - name: - id: name + old_field_1: + field: old_field_1 + id: old_field_1 table: views_test_data - field: name - style: - type: html_list display_plugin: default display_title: Master id: default position: '0' human_name: '' -name: test_field_output +name: test_views_move_to_field tag: '' diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml b/core/modules/views/tests/views_test_config/config/views.view.test_views_move_to_handler.yml similarity index 52% copy from core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml copy to core/modules/views/tests/views_test_config/config/views.view.test_views_move_to_handler.yml index 6d0d73f..35c75d0 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_views_move_to_handler.yml @@ -2,25 +2,24 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: - access: - type: none - cache: - type: none fields: - name: - id: name + old_field_2: + field: old_field_2 + id: old_field_2 + table: views_test_data + filters: + old_field_3: + field: old_field_3 + id: old_field_3 table: views_test_data - field: name - style: - type: html_list display_plugin: default display_title: Master id: default position: '0' human_name: '' -name: test_field_output +name: test_views_move_to_handler tag: '' diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_access_dynamic.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_access_dynamic.yml index a78537d..b803b0e 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_access_dynamic.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_access_dynamic.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_access_none.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_access_none.yml index 79019ef..bdc6fff 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_access_none.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_access_none.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_access_static.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_access_static.yml index cd3a94c..398b23b 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_access_static.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_access_static.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_aggregate_count.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_aggregate_count.yml index 7a42247..0503fcf 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_aggregate_count.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_aggregate_count.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_alias.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_alias.yml index 3755f24..394209f 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_alias.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_alias.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: users core: 8.0-dev description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_current_user.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_current_user.yml index 3cf754d..2f98257 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_current_user.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_current_user.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_fixed.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_fixed.yml index 061b209..95c27a0 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_fixed.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_fixed.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml index 3d3702e..01c63fd 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_cache.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_cache.yml index b15a64a..8a5f895 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_cache.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_cache.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_plugin: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_click_sort.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_click_sort.yml index 8aa2eb2..b11f642 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_click_sort.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_click_sort.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml index a28c6b1..e1a40f9 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '1' +status: '1' display: attachment_1: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml index d9c5430..3f044b4 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '1' +status: '1' display: block: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_display_attachment.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_display_attachment.yml index 82a87fc..283a740 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_display_attachment.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_display_attachment.yml @@ -3,7 +3,7 @@ base_field: id base_table: views_test_data core: 8.x description: '' -disabled: '0' +status: '1' display: default: display_plugin: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_dropbutton.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_dropbutton.yml index 2d4fe32..fbfda49 100755 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_dropbutton.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_dropbutton.yml @@ -3,7 +3,7 @@ base_field: nid base_table: node core: 8.x description: '' -disabled: '0' +status: '1' display: default: display_plugin: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_example_area.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_example_area.yml index 2a8fb0b..724b909 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_example_area.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_example_area.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_executable_displays.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_executable_displays.yml index f4645c4..4920202 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_executable_displays.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_executable_displays.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_plugin: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml index d73dfb8..e3db7a2 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_form.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_form.yml index 736ba03..7bcba8d 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_form.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_form.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml index 6ba9d11..63678af 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: 8.0-dev description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_classes.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_classes.yml index d2fe5b2..d390108 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_classes.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_classes.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml index 5ba2fc9..46d6aea 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: comment core: 8.0-dev description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml index 6d0d73f..594ff16 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_output.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_tokens.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_tokens.yml index 01431a6..ea1cf47 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_tokens.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_tokens.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_type.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_type.yml index c9172bc..d137c70 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_type.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_type.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter.yml index 3f11e83..e0a40c3 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter.yml @@ -1,7 +1,7 @@ api_version: '3.0' base_table: views_test_data core: 8 -disabled: false +status: true display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml index 71f4b2f..f69c4f2 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml index 379eff6..95b3450 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml index d71c02e..50db439 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml index a68c790..ac0d87d 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_in_operator_ui.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_get_attach_displays.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_get_attach_displays.yml index 96a1be7..8e5e670 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_get_attach_displays.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_get_attach_displays.yml @@ -99,6 +99,6 @@ display: default: default page_1: page_1 base_field: nid -disabled: '0' +status: '1' module: views langcode: und diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml index 33045e5..a23afff 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_count.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_count.yml index 7ea0ab8..a5ea4a2 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_count.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_count.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_in_filters.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_in_filters.yml index c494b09..28a9dc6 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_in_filters.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_group_by_in_filters.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml index 409fb2c..3945202 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_history.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_history.yml index ee816ef..765aebe 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_history.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_history.yml @@ -3,7 +3,7 @@ base_field: nid base_table: node core: 8.x description: '' -disabled: '0' +status: '1' display: default: display_plugin: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_page_display.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_page_display.yml index 92ed6c7..4a0906b 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_page_display.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_page_display.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_full.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_full.yml index 08be354..0b808f2 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_full.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_full.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_none.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_none.yml index 7b20316..40b79bd 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_none.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_none.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_some.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_some.yml index d9ecda5..57f7d4a 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_some.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_pager_some.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_preview.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_preview.yml index 91ba690..2ab7217 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_preview.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_preview.yml @@ -3,7 +3,7 @@ base_field: id base_table: views_test_data core: 8.x description: '' -disabled: '0' +status: '1' display: default: display_plugin: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml index 1217693..6946006 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml @@ -74,6 +74,6 @@ display: display_options: path: test-redirect-view base_field: nid -disabled: '0' +status: '1' module: views langcode: und diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_reset_button.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_reset_button.yml index e01c83e..5cf03ed 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_reset_button.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_reset_button.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_simple_argument.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_simple_argument.yml index 8f1e259..99a28b5 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_simple_argument.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_simple_argument.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_store_pager_settings.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_store_pager_settings.yml index 0c4acfe..26d11cf 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_store_pager_settings.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_store_pager_settings.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_style_mapping.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_style_mapping.yml index 30d4dd9..b9f34ef 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_style_mapping.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_style_mapping.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_tokens.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_tokens.yml index f6e640c..baa7de1 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_tokens.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_tokens.yml @@ -53,5 +53,5 @@ display: options: { } path: test_tokens base_field: id -disabled: '0' +status: '1' module: views diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view.yml index 57dd103..85742da 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_numeric.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_numeric.yml index 446aa63..2614c1b 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_numeric.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_numeric.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_php.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_php.yml index 1b4dc28..13808c9 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_php.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_argument_validate_php.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_delete.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_delete.yml index ca28db8..cf80152 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_delete.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_delete.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_handler_weight.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_handler_weight.yml index cf47d54..9cecaec 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_handler_weight.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_handler_weight.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml index 5b909ea..ad3fb4c 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_render.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_render.yml index e3ad228..4e7ffe3 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_render.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_render.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: views_test_data core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_status.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_status.yml index 08261f5..47cdaef 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_status.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_status.yml @@ -12,5 +12,5 @@ display: display_title: Master position: '' base_field: id -disabled: '1' +status: '0' module: views diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_views_groupby_save.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_views_groupby_save.yml index 05f9b5c..a5f74ee 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_views_groupby_save.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_views_groupby_save.yml @@ -2,7 +2,7 @@ api_version: '3.0' base_table: node core: '8' description: '' -disabled: '0' +status: '1' display: default: display_options: diff --git a/core/modules/views/views.module b/core/modules/views/views.module index f4d8404..b27b777 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -1127,7 +1127,7 @@ function views_get_applicable_views($type) { foreach ($views as $view) { // Skip disabled views. - if (!$view->isEnabled()) { + if (!$view->status()) { continue; } @@ -1261,9 +1261,11 @@ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclu * * @return bool * Returns TRUE if a view is enabled, FALSE otherwise. + * + * @todo Obsolete helper function; remove in favor of ::status() method. */ function views_view_is_enabled(View $view) { - return $view->isEnabled(); + return $view->status(); } /** @@ -1274,9 +1276,11 @@ function views_view_is_enabled(View $view) { * * @return bool * Returns TRUE if a view is disabled, FALSE otherwise. + * + * @todo Obsolete helper function; remove in favor of ::status() method. */ function views_view_is_disabled(View $view) { - return !$view->isEnabled(); + return !$view->status(); } /** @@ -1284,6 +1288,8 @@ function views_view_is_disabled(View $view) { * * @param Drupal\views\Plugin\Core\Entity\View $view * The View object to disable. + * + * @todo Obsolete helper function; remove in favor of ::enable() method. */ function views_enable_view(View $view) { $view->enable(); @@ -1294,6 +1300,8 @@ function views_enable_view(View $view) { * * @param Drupal\views\Plugin\Core\Entity\View $view * The View object to disable. + * + * @todo Obsolete helper function; remove in favor of ::disable() method. */ function views_disable_view(View $view) { $view->disable(); diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php index 46c139b..8bc8db1 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewListController.php @@ -19,18 +19,14 @@ class ViewListController extends EntityListController { * Overrides Drupal\Core\Entity\EntityListController::load(); */ public function load() { - $entities = array( - 'enabled' => array(), - 'disabled' => array(), - ); - foreach (parent::load() as $entity) { - if ($entity->isEnabled()) { - $entities['enabled'][] = $entity; - } - else { - $entities['disabled'][] = $entity; + $entities = parent::load(); + uasort($entities, function ($a, $b) { + $a_enabled = $a->status(); + $b_enabled = $b->status(); + if ($a_enabled != $b_enabled) { + return $a_enabled < $b_enabled; } - } + }); return $entities; } @@ -49,7 +45,7 @@ public function buildRow(EntityInterface $view) { ), ), 'title' => t('Machine name: ') . $view->id(), - 'class' => array($view->isEnabled() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'), + 'class' => array($view->status() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'), ); } @@ -82,7 +78,9 @@ public function buildHeader() { } /** - * Implements Drupal\Core\Entity\EntityListController::getOperations(); + * Implements Drupal\Core\Entity\EntityListController::getOperations(). + * + * @todo Obsolete after extending from ConfigEntityListController. */ public function getOperations(EntityInterface $view) { $uri = $view->uri(); @@ -93,7 +91,7 @@ public function getOperations(EntityInterface $view) { 'href' => "$path/edit", 'weight' => -5, ); - if (!$view->isEnabled()) { + if (!$view->status()) { $definition['enable'] = array( 'title' => t('Enable'), 'ajax' => TRUE, diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php index db6c900..cb066f1 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -1047,23 +1047,23 @@ public function getProperties($include_computed = FALSE) { } /** - * Implements \Drupal\views\ViewStorageInterface::enable(). + * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::enable(). */ public function enable() { return $this->__call(__FUNCTION__, func_get_args()); } /** - * Implements \Drupal\views\ViewStorageInterface::disable(). + * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::disable(). */ public function disable() { return $this->__call(__FUNCTION__, func_get_args()); } /** - * Implements \Drupal\views\ViewStorageInterface::isEnabled(). + * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::status(). */ - public function isEnabled() { + public function status() { return $this->__call(__FUNCTION__, func_get_args()); } diff --git a/core/modules/views/views_ui/views_ui.module b/core/modules/views/views_ui/views_ui.module index e3e9362..5abd8e1 100644 --- a/core/modules/views/views_ui/views_ui.module +++ b/core/modules/views/views_ui/views_ui.module @@ -686,8 +686,9 @@ function views_ui_load($name) { * redirect back to the listing page. */ function views_ui_ajax_callback(ViewExecutable $view, $op) { - // Perform the operation. + // Perform the operation and save the view. $view->storage->$op(); + $view->save(); // If the request is via AJAX, return the rendered list as JSON. if (drupal_container()->get('request')->request->get('js')) {