diff --git a/core/modules/block_content/block_content.install b/core/modules/block_content/block_content.install index c6556e7..6a183c9 100644 --- a/core/modules/block_content/block_content.install +++ b/core/modules/block_content/block_content.install @@ -138,3 +138,190 @@ function block_content_update_8400() { $definition_update_manager->uninstallFieldStorageDefinition($content_translation_status); } } + +/** + * 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'); + // 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', + ]; + $view->set('display.default.display_options.fields.block_content_bulk_form', $block_content_bulk_form); + $status = [ + 'id' => 'status', + 'table' => 'block_content_field_data', + 'field' => 'status', + 'relationship' => 'none', + 'group_type' => 'group', + 'admin_label' => '', + 'label' => 'Published', + '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' => true, + 'element_wrapper_type' => '', + 'element_wrapper_class' => '', + 'element_default_classes' => true, + 'empty' => '', + 'hide_empty' => false, + 'empty_zero' => false, + 'hide_alter_empty' => true, + 'click_sort_column' => 'value', + 'type' => 'boolean', + 'settings' => [ + 'format' => 'yes-no', + 'format_custom_true' => '', + 'format_custom_false' => '', + ], + 'group_column' => 'value', + 'group_columns' => [], + 'group_rows' => true, + 'delta_limit' => 0, + 'delta_offset' => 0, + 'delta_reversed' => false, + 'delta_first_last' => false, + 'multi_type' => 'separator', + 'separator' => '', + 'field_api_classes' => false, + 'entity_type' => 'block_content', + 'entity_field' => 'status', + 'plugin_id' => 'field', + ]; + $view->set('display.default.display_options.fields.status', $status); + + // Add exposed status filter. + $status_filter = [ + 'id' => 'status', + 'table' => 'block_content_field_data', + 'field' => 'status', + 'relationship' => 'none', + 'group_type' => 'group', + 'admin_label' => '', + 'operator' => '', + 'value' => 'All', + 'group' => 1, + 'exposed' => true, + 'expose' => [ + 'operator_id' => '', + 'label' => 'Published', + 'description' => '', + 'use_operator' => false, + 'operator' => 'status_op', + 'identifier' => 'status', + 'required' => false, + 'remember' => false, + 'multiple' => false, + 'remember_roles' => [ + 'authenticated' => 'authenticated', + 'anonymous' => '0', + 'administrator' => '0', + ], + ], + 'is_grouped' => false, + 'group_info' => [ + 'label' => '', + 'description' => '', + 'identifier' => '', + 'optional' => true, + 'widget' => 'select', + 'multiple' => false, + 'remember' => false, + 'default_group' => 'All', + 'default_group_multiple' => [], + 'group_items' => [], + ], + 'entity_type' => 'block_content', + 'entity_field' => 'status', + 'plugin_id' => 'boolean', + ]; + $view->set('display.default.display_options.filters.status', $status_filter); + $view->save(); +}