diff --git a/core/modules/block_content/block_content.install b/core/modules/block_content/block_content.install index 5b22319..cac122d 100644 --- a/core/modules/block_content/block_content.install +++ b/core/modules/block_content/block_content.install @@ -7,6 +7,7 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\ViewExecutable; /** * Implements hook_update_dependencies(). @@ -143,8 +144,10 @@ function block_content_update_8400() { * Update block_content view to reflect publishable block_content blocks. */ function block_content_update_8600() { - $view = \Drupal::service('config.factory')->getEditable('views.view.block_content'); + $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); + $entity_type = $definition_update_manager->getEntityType('block_content'); + $published_key = $entity_type->getKey('published'); // Get existing field configuration. $fields = $view->get("display.default.display_options.fields"); @@ -158,47 +161,47 @@ function block_content_update_8600() { 'group_type' => 'group', 'admin_label' => '', 'label' => '', - 'exclude' => false, + 'exclude' => FALSE, 'alter' => [ - 'alter_text' => false, + 'alter_text' => FALSE, 'text' => '', - 'make_link' => false, + 'make_link' => FALSE, 'path' => '', - 'absolute' => false, - 'external' => false, - 'replace_spaces' => false, + 'absolute' => FALSE, + 'external' => FALSE, + 'replace_spaces' => FALSE, 'path_case' => 'none', - 'trim_whitespace' => false, + 'trim_whitespace' => FALSE, 'alt' => '', 'rel' => '', 'link_class' => '', 'prefix' => '', 'suffix' => '', 'target' => '', - 'nl2br' => false, + 'nl2br' => FALSE, 'max_length' => 0, - 'word_boundary' => true, - 'ellipsis' => true, - 'more_link' => false, + 'word_boundary' => TRUE, + 'ellipsis' => TRUE, + 'more_link' => FALSE, 'more_link_text' => '', 'more_link_path' => '', - 'strip_tags' => false, - 'trim' => false, + 'strip_tags' => FALSE, + 'trim' => FALSE, 'preserve_tags' => '', - 'html' => false, + 'html' => FALSE, ], 'element_type' => '', 'element_class' => '', 'element_label_type' => '', 'element_label_class' => '', - 'element_label_colon' => false, + 'element_label_colon' => FALSE, 'element_wrapper_type' => '', 'element_wrapper_class' => '', - 'element_default_classes' => true, + 'element_default_classes' => TRUE, 'empty' => '', - 'hide_empty' => false, - 'empty_zero' => false, - 'hide_alter_empty' => true, + 'hide_empty' => FALSE, + 'empty_zero' => FALSE, + 'hide_alter_empty' => TRUE, 'action_title' => 'Action', 'include_exclude' => 'exclude', 'selected_actions' => [], @@ -210,54 +213,54 @@ function block_content_update_8600() { $combined_fields = $block_content_bulk_form + $fields; $status = [ 'status' => [ - 'id' => 'status', + 'id' => ViewExecutable::generateHandlerId($published_key, $view->get("display.default.display_options.fields")), 'table' => 'block_content_field_data', - 'field' => 'status', + 'field' => $published_key, 'relationship' => 'none', 'group_type' => 'group', 'admin_label' => '', 'label' => 'Published', - 'exclude' => false, + 'exclude' => FALSE, 'alter' => [ - 'alter_text' => false, + 'alter_text' => FALSE, 'text' => '', - 'make_link' => false, + 'make_link' => FALSE, 'path' => '', - 'absolute' => false, - 'external' => false, - 'replace_spaces' => false, + 'absolute' => FALSE, + 'external' => FALSE, + 'replace_spaces' => FALSE, 'path_case' => 'none', - 'trim_whitespace' => false, + 'trim_whitespace' => FALSE, 'alt' => '', 'rel' => '', 'link_class' => '', 'prefix' => '', 'suffix' => '', 'target' => '', - 'nl2br' => false, + 'nl2br' => FALSE, 'max_length' => 0, - 'word_boundary' => true, - 'ellipsis' => true, - 'more_link' => false, + 'word_boundary' => TRUE, + 'ellipsis' => TRUE, + 'more_link' => FALSE, 'more_link_text' => '', 'more_link_path' => '', - 'strip_tags' => false, - 'trim' => false, + 'strip_tags' => FALSE, + 'trim' => FALSE, 'preserve_tags' => '', - 'html' => false, + 'html' => FALSE, ], 'element_type' => '', 'element_class' => '', 'element_label_type' => '', 'element_label_class' => '', - 'element_label_colon' => true, + 'element_label_colon' => TRUE, 'element_wrapper_type' => '', 'element_wrapper_class' => '', - 'element_default_classes' => true, + 'element_default_classes' => TRUE, 'empty' => '', - 'hide_empty' => false, - 'empty_zero' => false, - 'hide_alter_empty' => true, + 'hide_empty' => FALSE, + 'empty_zero' => FALSE, + 'hide_alter_empty' => TRUE, 'click_sort_column' => 'value', 'type' => 'boolean', 'settings' => [ @@ -267,14 +270,14 @@ function block_content_update_8600() { ], 'group_column' => 'value', 'group_columns' => [], - 'group_rows' => true, + 'group_rows' => TRUE, 'delta_limit' => 0, 'delta_offset' => 0, - 'delta_reversed' => false, - 'delta_first_last' => false, + 'delta_reversed' => FALSE, + 'delta_first_last' => FALSE, 'multi_type' => 'separator', 'separator' => '', - 'field_api_classes' => false, + 'field_api_classes' => FALSE, 'entity_type' => 'block_content', 'entity_field' => 'status', 'plugin_id' => 'field', @@ -287,41 +290,41 @@ function block_content_update_8600() { // Add exposed status filter. $status_filter = [ - 'id' => 'status', + 'id' => ViewExecutable::generateHandlerId($published_key, $view->get("display.default.display_options.filters")), 'table' => 'block_content_field_data', - 'field' => 'status', + 'field' => $published_key, 'relationship' => 'none', 'group_type' => 'group', 'admin_label' => '', 'operator' => '', 'value' => 'All', 'group' => 1, - 'exposed' => true, + 'exposed' => TRUE, 'expose' => [ 'operator_id' => '', 'label' => 'Published', 'description' => '', - 'use_operator' => false, + 'use_operator' => FALSE, 'operator' => 'status_op', 'identifier' => 'status', - 'required' => false, - 'remember' => false, - 'multiple' => false, + 'required' => FALSE, + 'remember' => FALSE, + 'multiple' => FALSE, 'remember_roles' => [ 'authenticated' => 'authenticated', 'anonymous' => '0', 'administrator' => '0', ], ], - 'is_grouped' => false, + 'is_grouped' => FALSE, 'group_info' => [ 'label' => '', 'description' => '', 'identifier' => '', - 'optional' => true, + 'optional' => TRUE, 'widget' => 'select', - 'multiple' => false, - 'remember' => false, + 'multiple' => FALSE, + 'remember' => FALSE, 'default_group' => 'All', 'default_group_multiple' => [], 'group_items' => [], @@ -337,7 +340,7 @@ function block_content_update_8600() { $publish_action = \Drupal::service('config.factory')->getEditable('system.action.block_content_publish_action'); $config_data_publish = [ "langcode" => "en", - "status" => true, + "status" => TRUE, "dependencies" => [ "module" => [ "block_content" @@ -356,7 +359,7 @@ function block_content_update_8600() { $unpublish_action = \Drupal::service('config.factory')->getEditable('system.action.block_content_unpublish_action'); $config_data_unpublish = [ "langcode" => "en", - "status" => true, + "status" => TRUE, "dependencies" => [ "module" => [ "block_content" diff --git a/core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php b/core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php index 626af81..e9e96d5 100644 --- a/core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php +++ b/core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php @@ -92,14 +92,14 @@ public function testBlockContentPublishableUIUpdate() { $this->assertTrue($data['display']['default']['display_options']['filters']['status']['exposed'], "The status filter is exposed"); // Check the new actions were created and work as expected. - $user = $this->drupalCreateUser(['administer blocks', 'administer block_content display']); + $user = $this->drupalCreateUser(['administer blocks', 'administer block_content display']); $this->drupalLogin($user); // Create a block. $block_title = 'Test Block'; $edit = []; $edit['info[0][value]'] = $block_title; $edit['body[0][value]'] = $this->randomMachineName(16); - $this->drupalPostForm('block/add/basic', $edit, t('Save')); + $this->drupalPostForm('block/add/basic', $edit, 'Save'); // Check that the new block is displayed and showing its published status. $this->drupalGet('admin/structure/block/block-content'); @@ -107,33 +107,33 @@ public function testBlockContentPublishableUIUpdate() { $this->assertText('Yes', "Block displayed as published"); // Unpublish the block using the new unpublish action. - $edit =[]; + $edit = []; $edit['action'] = 'block_content_unpublish_action'; $edit['block_content_bulk_form[0]'] = TRUE; - $this->drupalPostForm('admin/structure/block/block-content', $edit, t('Apply to selected items')); + $this->drupalPostForm('admin/structure/block/block-content', $edit, 'Apply to selected items'); $this->assertText('Unpublish block content was applied to 1 item.'); $this->assertText($block_title); $this->assertText('No', "Block displayed as unpublished"); // Filter by unpublished to show only unpublished blocks. - $edit =[]; + $edit = []; $edit['status'] = 0; - $this->drupalPostForm('admin/structure/block/block-content', $edit, t('Apply')); + $this->drupalPostForm('admin/structure/block/block-content', $edit, 'Apply'); $this->assertText($block_title); $this->assertText('No', "Block displayed as unpublished"); // Publish the block using the new publish action. - $edit =[]; + $edit = []; $edit['action'] = 'block_content_publish_action'; $edit['block_content_bulk_form[0]'] = TRUE; - $this->drupalPostForm('admin/structure/block/block-content', $edit, t('Apply to selected items')); + $this->drupalPostForm('admin/structure/block/block-content', $edit, 'Apply to selected items'); $this->assertText('Publish block content was applied to 1 item.'); $this->assertText('Yes', "Block displayed as unpublished"); // Filter by published to show only published blocks. - $edit =[]; + $edit = []; $edit['status'] = 1; - $this->drupalPostForm('admin/structure/block/block-content', $edit, t('Apply')); + $this->drupalPostForm('admin/structure/block/block-content', $edit, 'Apply'); $this->assertText($block_title); $this->assertText('Yes', "Block displayed as published"); }