diff --git a/core/modules/block_content/block_content.install b/core/modules/block_content/block_content.install index 6a183c9f35..bd27ca2e78 100644 --- a/core/modules/block_content/block_content.install +++ b/core/modules/block_content/block_content.install @@ -145,66 +145,70 @@ function block_content_update_8400() { function block_content_update_8600() { $view = \Drupal::service('config.factory')->getEditable('views.view.block_content'); + + // Get existing field configuration. + $fields = $view->get ("display.default.display_options.fields"); // Add bulk form and status fields. $block_content_bulk_form = [ - 'id' => 'block_content_bulk_form', - 'table' => 'block_content', - 'field' => 'block_content_bulk_form', - 'relationship' => 'none', - 'group_type' => 'group', - 'admin_label' => '', - 'label' => '', - 'exclude' => false, - 'alter' => [ - 'alter_text' => false, - 'text' => '', - 'make_link' => false, - 'path' => '', - 'absolute' => false, - 'external' => false, - 'replace_spaces' => false, - 'path_case' => 'none', - 'trim_whitespace' => false, - 'alt' => '', - 'rel' => '', - 'link_class' => '', - 'prefix' => '', - 'suffix' => '', - 'target' => '', - 'nl2br' => false, - 'max_length' => 0, - 'word_boundary' => true, - 'ellipsis' => true, - 'more_link' => false, - 'more_link_text' => '', - 'more_link_path' => '', - 'strip_tags' => false, - 'trim' => false, - 'preserve_tags' => '', - 'html' => false, - ], - 'element_type' => '', - 'element_class' => '', - 'element_label_type' => '', - 'element_label_class' => '', - 'element_label_colon' => false, - 'element_wrapper_type' => '', - 'element_wrapper_class' => '', - 'element_default_classes' => true, - 'empty' => '', - 'hide_empty' => false, - 'empty_zero' => false, - 'hide_alter_empty' => true, - 'action_title' => 'Action', - 'include_exclude' => 'include', - 'selected_actions' => [ - 'block_content_publish_action' => true, - 'block_content_unpublish_action' => true, - ], - 'entity_type' => 'block_content', - 'plugin_id' => 'block_content_bulk_form', + 'block_content_bulk_form' => [ + 'id' => 'block_content_bulk_form', + 'table' => 'block_content', + 'field' => 'block_content_bulk_form', + 'relationship' => 'none', + 'group_type' => 'group', + 'admin_label' => '', + 'label' => '', + 'exclude' => false, + 'alter' => [ + 'alter_text' => false, + 'text' => '', + 'make_link' => false, + 'path' => '', + 'absolute' => false, + 'external' => false, + 'replace_spaces' => false, + 'path_case' => 'none', + 'trim_whitespace' => false, + 'alt' => '', + 'rel' => '', + 'link_class' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'nl2br' => false, + 'max_length' => 0, + 'word_boundary' => true, + 'ellipsis' => true, + 'more_link' => false, + 'more_link_text' => '', + 'more_link_path' => '', + 'strip_tags' => false, + 'trim' => false, + 'preserve_tags' => '', + 'html' => false, + ], + 'element_type' => '', + 'element_class' => '', + 'element_label_type' => '', + 'element_label_class' => '', + 'element_label_colon' => false, + 'element_wrapper_type' => '', + 'element_wrapper_class' => '', + 'element_default_classes' => true, + 'empty' => '', + 'hide_empty' => false, + 'empty_zero' => false, + 'hide_alter_empty' => true, + 'action_title' => 'Action', + 'include_exclude' => 'exclude', + 'selected_actions' => [], + 'entity_type' => 'block_content', + 'plugin_id' => 'block_content_bulk_form', + ] ]; - $view->set('display.default.display_options.fields.block_content_bulk_form', $block_content_bulk_form); + // Merge new field with existing fields. + $combined_fields = $block_content_bulk_form + $fields; + $view->set('display.default.display_options.fields', $combined_fields); $status = [ 'id' => 'status', 'table' => 'block_content_field_data', @@ -324,4 +328,42 @@ function block_content_update_8600() { ]; $view->set('display.default.display_options.filters.status', $status_filter); $view->save(); + + // Add publish action. + $publish_action = \Drupal::service('config.factory')->getEditable('system.action.block_content_publish_action'); + $config_data_publish = [ + "langcode" => "en", + "status" => true, + "dependencies" => [ + "module" => [ + "block_content" + ] + ], + "id" => "block_content_publish_action", + "label" => "Publish block content", + "type" => "block_content", + "plugin" => "entity:publish_action:block_content", + "configuration" => [] + ]; + $publish_action->setData($config_data_publish); + $publish_action->save(); + + // Add unpublish action. + $unpublish_action = \Drupal::service('config.factory')->getEditable('system.action.block_content_unpublish_action'); + $config_data_unpublish = [ + "langcode" => "en", + "status" => true, + "dependencies" => [ + "module" => [ + "block_content" + ] + ], + "id" => "block_content_unpublish_action", + "label" => "Unpublish block content", + "type" => "block_content", + "plugin" => "entity:unpublish_action:block_content", + "configuration" => [] + ]; + $unpublish_action->setData($config_data_unpublish); + $unpublish_action->save(); }