Skip to content
Snippets Groups Projects
Verified Commit d7c4cf1b authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2862564 by smustgrave, Manuel Garcia, ifrik, acbramley, amjad1233,...

Issue #2862564 by smustgrave, Manuel Garcia, ifrik, acbramley, amjad1233, benjifisher, manuel.adan, Anchal_gupta, tedbow, Lendude, yogeshmpawar, larowlan, rkoller, AaronMcHale, gambry, rachel_norfolk, yoroy, xjm, Webbeh, catch, mstrelan: Move Custom block library to Content
parent 5b8bef8a
Branches
Tags
29 merge requests!12227Issue #3181946 by jonmcl, mglaman,!54479.5.x SF update,!5014Issue #3071143: Table Render Array Example Is Incorrect,!4868Issue #1428520: Improve menu parent link selection,!4289Issue #1344552 by marcingy, Niklas Fiekas, Ravi.J, aleevas, Eduardo Morales...,!4114Issue #2707291: Disable body-level scrolling when a dialog is open as a modal,!4100Issue #3249600: Add support for PHP 8.1 Enums as allowed values for list_* data types,!3630Issue #2815301 by Chi, DanielVeza, kostyashupenko, smustgrave: Allow to create...,!3600Issue #3344629: Passing null to parameter #1 ($haystack) of type string is deprecated,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1591Issue #3199697: Add JSON:API Translation experimental module,!1484Exposed filters get values from URL when Ajax is on,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1162Issue #3100350: Unable to save '/' root path alias,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!925Issue #2339235: Remove taxonomy hard dependency on node module,!877Issue #2708101: Default value for link text is not saved,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!844Resolve #3036010 "Updaters",!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!213Issue #2906496: Give Media a menu item under Content,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
Showing
with 736 additions and 43 deletions
......@@ -37,9 +37,3 @@ tips:
weight: 4
selector: .dropbutton-widget
body: 'By Clicking on "Configure" you can go ahead and edit the contents of the block, deal with the visibility settings and even change the placement of where it is on your theme.'
custom-block-library:
id: custom-block-library
plugin: text
label: 'Custom Block Library'
weight: 5
body: 'The block management screen also has an another tab on the top which is used to add Custom blocks. The name of the tab is "Custom block library". This tab ultimately provides a link to add custom blocks.'
entity.block_content.collection:
title: 'Custom block library'
title: Custom blocks
route_name: entity.block_content.collection
base_route: block.admin_display
base_route: system.admin_content
entity.block_content.canonical:
title: Edit
......
......@@ -22,20 +22,16 @@ function block_content_help($route_name, RouteMatchInterface $route_match) {
$field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? Url::fromRoute('help.page', ['name' => 'field_ui'])->toString() : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Custom Block module allows you to create and manage custom <em>block types</em> from the <a href=":types">Custom Block types</a> page and <em>content-containing blocks</em> from the <a href=":block-library">Custom block library</a> page. Custom block types have fields; see the <a href=":field-help">Field module help</a> for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the <a href=":blocks">Block module help</a> page for details. For more information, see the <a href=":online-help">online documentation for the Custom Block module</a>.', [':types' => Url::fromRoute('entity.block_content_type.collection')->toString(), ':block-library' => Url::fromRoute('entity.block_content.collection')->toString(), ':field-help' => Url::fromRoute('help.page', ['name' => 'field'])->toString(), ':blocks' => Url::fromRoute('help.page', ['name' => 'block'])->toString(), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content']) . '</p>';
$output .= '<p>' . t('The Custom Block module allows you to create and manage custom <em>block types</em> and <em>content-containing blocks</em>. For more information, see the <a href=":online-help">online documentation for the Custom Block module</a>.', [':online-help' => 'https://www.drupal.org/documentation/modules/block_content']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating and managing custom block types') . '</dt>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create and edit custom block types with fields and display settings, from the <a href=":types">Custom Block types</a> page under the Structure menu. For more information about managing fields and display settings, see the <a href=":field-ui">Field UI module help</a>.', [':types' => Url::fromRoute('entity.block_content_type.collection')->toString(), ':field-ui' => $field_ui]) . '</dd>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create and edit custom block types with fields and display settings, from the <a href=":types">Custom Block types</a> page under the Structure menu. For more information about managing fields and display settings, see the <a href=":field-ui">Field UI module help</a> and <a href=":field">Field module help</a>.', [':types' => Url::fromRoute('entity.block_content_type.collection')->toString(), ':field-ui' => $field_ui, ':field' => Url::fromRoute('help.page', ['name' => 'field'])->toString()]) . '</dd>';
$output .= '<dt>' . t('Creating custom blocks') . '</dt>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create, edit, and delete custom blocks of each defined custom block type, from the <a href=":block-library">Custom block library</a>. After creating a block, place it in a region from the <a href=":blocks">Block layout page</a>.', [':blocks' => Url::fromRoute('block.admin_display')->toString(), ':block-library' => Url::fromRoute('entity.block_content.collection')->toString()]) . '</dd>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create, edit, and delete custom blocks of each defined custom block type, from the <a href=":block-library">Custom blocks page</a>. After creating a block, place it in a region from the <a href=":blocks">Block layout page</a>, just like blocks provided by other modules.', [':blocks' => Url::fromRoute('block.admin_display')->toString(), ':block-library' => Url::fromRoute('entity.block_content.collection')->toString()]) . '</dd>';
$output .= '</dl>';
return $output;
case 'entity.block_content.collection':
$output = '<p>' . t('Blocks in the block library belong to <a href=":types">Custom block types</a>, each with its own fields and display settings. After creating a block, place it in a region from the <a href=":blocks">Block layout</a> page.', [':types' => Url::fromRoute('entity.block_content_type.collection')->toString(), ':blocks' => Url::fromRoute('block.admin_display')->toString()]) . '</p>';
return $output;
}
}
......
......@@ -5,6 +5,8 @@
* Post update functions for Custom Block.
*/
use Drupal\views\Entity\View;
/**
* Implements hook_removed_post_updates().
*/
......@@ -20,3 +22,29 @@ function block_content_removed_post_updates() {
function block_content_post_update_entity_changed_constraint() {
// Empty post_update hook.
}
/**
* Moves the custom block library to Content.
*/
function block_content_post_update_move_custom_block_library() {
if (!\Drupal::service('module_handler')->moduleExists('views')) {
return;
}
if (!$view = View::load('block_content')) {
return;
}
$display =& $view->getDisplay('page_1');
if (empty($display) || $display['display_options']['path'] !== 'admin/structure/block/block-content') {
return;
}
$display['display_options']['path'] = 'admin/content/block-content';
$menu =& $display['display_options']['menu'];
$menu['description'] = 'Create and edit custom block content.';
$menu['expanded'] = FALSE;
$menu['parent'] = 'system.admin_content';
$view->save();
}
......@@ -72,9 +72,20 @@ block_content.type_add:
_permission: 'administer blocks'
entity.block_content.collection:
path: '/admin/structure/block/block-content'
path: '/admin/content/block-content'
defaults:
_title: 'Custom block library'
_title: 'Custom blocks'
_entity_list: 'block_content'
requirements:
_permission: 'administer blocks'
# @todo Deprecate this route once
# https://www.drupal.org/project/drupal/issues/3159210 is fixed, or remove
# it in Drupal 11.
# @see https://www.drupal.org/node/3320855
entity.block_content.collection.bc:
path: '/admin/structure/block/block-content'
defaults:
_controller: '\Drupal\block_content\Controller\BlockContentController::blockLibraryRedirect'
requirements:
_permission: 'administer blocks'
......@@ -5,7 +5,7 @@ dependencies:
- block_content
- user
id: block_content
label: 'Custom block library'
label: 'Custom blocks'
module: views
description: 'Find and manage custom blocks.'
tag: default
......@@ -18,7 +18,7 @@ display:
display_plugin: default
position: 0
display_options:
title: 'Custom block library'
title: 'Custom blocks'
fields:
info:
id: info
......@@ -520,14 +520,14 @@ display:
position: 1
display_options:
display_extenders: { }
path: admin/structure/block/block-content
path: admin/content/block-content
menu:
type: tab
title: 'Custom block library'
description: ''
title: 'Custom blocks'
description: 'Create and edit custom block content.'
weight: 0
menu_name: admin
parent: block.admin_display
parent: system.admin_content
context: '0'
cache_metadata:
max-age: -1
......
......@@ -155,4 +155,31 @@ public function blockContentTypeRedirect(): RedirectResponse {
return $this->redirect($route, [], [], 301);
}
/**
* Provides a redirect to the custom block library.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
* /admin/content/block-content directly instead of
* /admin/structure/block/block-content.
*
* @see https://www.drupal.org/node/3320855
*/
public function blockLibraryRedirect() {
@trigger_error('The path /admin/structure/block/block-content is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/content/block-content. See https://www.drupal.org/node/3320855.', E_USER_DEPRECATED);
$route = 'entity.block_content.collection';
$params = [
'%old_path' => Url::fromRoute("$route.bc")->toString(),
'%new_path' => Url::fromRoute($route)->toString(),
'%change_record' => 'https://www.drupal.org/node/3320855',
];
$warning_message = $this->t('You have been redirected from %old_path. Update links, shortcuts, and bookmarks to use %new_path.', $params);
$this->messenger()->addWarning($warning_message);
$this->getLogger('block_content')
->warning('A user was redirected from %old_path to %new_path. This redirect will be removed in a future version of Drupal. Update links, shortcuts, and bookmarks to use %new_path. See %change_record for more information.', $params);
return $this->redirect($route, [], [], 301);
}
}
......@@ -53,7 +53,7 @@
* "canonical" = "/block/{block_content}",
* "delete-form" = "/block/{block_content}/delete",
* "edit-form" = "/block/{block_content}",
* "collection" = "/admin/structure/block/block-content",
* "collection" = "/admin/content/block-content",
* "create" = "/block",
* "revision-delete-form" = "/block/{block_content}/revision/{block_content_revision}/delete",
* "revision-revert-form" = "/block/{block_content}/revision/{block_content_revision}/revert",
......
langcode: en
status: true
dependencies:
module:
- block_content
- user
id: block_content
label: 'Custom blocks'
module: views
description: 'Create and edit custom block content.'
tag: default
base_table: block_content_field_data
base_field: id
display:
default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options:
title: 'Custom blocks'
fields:
info:
id: info
table: block_content_field_data
field: info
relationship: none
group_type: group
admin_label: ''
entity_type: null
entity_field: info
plugin_id: field
label: 'Block description'
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: string
settings:
link_to_entity: true
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
type:
id: type
table: block_content_field_data
field: type
relationship: none
group_type: group
admin_label: ''
entity_type: block_content
entity_field: type
plugin_id: field
label: 'Block type'
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: target_id
type: entity_reference_label
settings:
link: false
group_column: target_id
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
changed:
id: changed
table: block_content_field_data
field: changed
relationship: none
group_type: group
admin_label: ''
entity_type: block_content
entity_field: changed
plugin_id: field
label: Updated
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
type: timestamp
settings:
date_format: short
custom_date_format: ''
timezone: ''
operations:
id: operations
table: block_content
field: operations
relationship: none
group_type: group
admin_label: ''
entity_type: block_content
plugin_id: entity_operations
label: Operations
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
destination: true
pager:
type: mini
options:
offset: 0
items_per_page: 50
total_pages: null
id: 0
tags:
next: 'Next ›'
previous: ' Previous'
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: true
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
access:
type: perm
options:
perm: 'administer blocks'
cache:
type: tag
options: { }
empty:
area_text_custom:
id: area_text_custom
table: views
field: area_text_custom
relationship: none
group_type: group
admin_label: ''
plugin_id: text_custom
empty: true
content: 'There are no custom blocks available.'
tokenize: false
block_content_listing_empty:
id: block_content_listing_empty
table: block_content
field: block_content_listing_empty
relationship: none
group_type: group
admin_label: ''
entity_type: block_content
plugin_id: block_content_listing_empty
label: ''
empty: true
sorts: { }
arguments: { }
filters:
info:
id: info
table: block_content_field_data
field: info
relationship: none
group_type: group
admin_label: ''
entity_type: block_content
entity_field: info
plugin_id: string
operator: contains
value: ''
group: 1
exposed: true
expose:
operator_id: info_op
label: 'Block description'
description: ''
use_operator: false
operator: info_op
operator_limit_selection: false
operator_list: { }
identifier: info
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: { }
type:
id: type
table: block_content_field_data
field: type
relationship: none
group_type: group
admin_label: ''
entity_type: block_content
entity_field: type
plugin_id: bundle
operator: in
value: { }
group: 1
exposed: true
expose:
operator_id: type_op
label: 'Block type'
description: ''
use_operator: false
operator: type_op
operator_limit_selection: false
operator_list: { }
identifier: type
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reusable:
id: reusable
table: block_content_field_data
field: reusable
relationship: none
group_type: group
admin_label: ''
entity_type: block_content
entity_field: reusable
plugin_id: boolean
operator: '='
value: '1'
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
style:
type: table
options:
grouping: { }
row_class: ''
default_row_class: true
columns:
info: info
type: type
changed: changed
operations: operations
default: changed
info:
info:
sortable: true
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
type:
sortable: true
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
changed:
sortable: true
default_sort_order: desc
align: ''
separator: ''
empty_column: false
responsive: ''
operations:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
override: true
sticky: false
summary: ''
empty_table: true
caption: ''
description: ''
row:
type: fields
query:
type: views_query
options:
query_comment: ''
disable_sql_rewrite: false
distinct: false
replica: false
query_tags: { }
relationships: { }
header: { }
footer: { }
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
tags: { }
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 1
display_options:
display_extenders: { }
path: admin/content/block-content
menu:
type: tab
title: 'Custom blocks'
description: 'Create and edit custom block content.'
weight: 0
menu_name: admin
parent: system.admin_content
context: '0'
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
tags: { }
......@@ -35,10 +35,10 @@ public function testListing() {
'administer blocks',
'translate configuration',
]));
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
// Test for the page title.
$this->assertSession()->titleEquals('Custom block library | Drupal');
$this->assertSession()->titleEquals('Custom blocks | Drupal');
// Test for the table.
$this->assertSession()->elementExists('xpath', '//div[@class="layout-content"]//table');
......@@ -113,7 +113,7 @@ public function testListing() {
]);
$block_content->save();
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
// Confirm that the empty text is displayed.
$this->assertSession()->pageTextContains('There are no custom blocks yet.');
// Confirm the non-reusable block is not on the page.
......
......@@ -38,10 +38,10 @@ public function testListing() {
'administer blocks',
'translate configuration',
]));
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
// Test for the page title.
$this->assertSession()->titleEquals('Custom block library | Drupal');
$this->assertSession()->titleEquals('Custom blocks | Drupal');
// Test for the exposed filters.
$this->assertSession()->fieldExists('info');
......@@ -124,7 +124,7 @@ public function testListing() {
]);
$block_content->save();
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
// Confirm that the empty text is displayed.
$this->assertSession()->pageTextContains('There are no custom blocks available.');
// Confirm the non-reusable block is not on the page.
......
......@@ -125,7 +125,7 @@ protected function doTestBasicTranslation() {
}
// Check that the translate operation link is shown.
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
$this->assertSession()->linkByHrefExists('block/' . $entity->id() . '/translations');
}
......
......@@ -241,7 +241,7 @@ public function testsBlockContentAddTypes() {
// Test that adding a block from the 'custom blocks list' doesn't send you
// to the block configure form.
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
$this->clickLink('Add custom block');
$this->clickLink('foo');
$edit = ['info[0][value]' => $this->randomMachineName(8)];
......@@ -265,7 +265,22 @@ public function testBlockContentTypeRedirect() {
$this->expectDeprecation('The path /admin/structure/block/block-content/types is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/structure/block-content. See https://www.drupal.org/node/3320855.');
$this->drupalGet('/admin/structure/block/block-content/types');
$base_path = parse_url($this->baseUrl, PHP_URL_PATH) ?? '';
$this->assertSession()->pageTextContains("You have been redirected from $base_path/admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use $base_path/admin/structure/block-content.");
$this->assertSession()
->pageTextContains("You have been redirected from $base_path/admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use $base_path/admin/structure/block-content.");
}
/**
* Tests the deprecation message from the old block library page.
*
* @group legacy
*/
public function testBlockLibraryRedirect() {
$this->drupalLogin($this->adminUser);
$this->expectDeprecation('The path /admin/structure/block/block-content is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/content/block-content. See https://www.drupal.org/node/3320855.');
$this->drupalGet('admin/structure/block/block-content');
$base_path = parse_url($this->baseUrl, PHP_URL_PATH) ?? '';
$this->assertSession()
->pageTextContains("You have been redirected from $base_path/admin/structure/block/block-content. Update links, shortcuts, and bookmarks to use $base_path/admin/content/block-content.");
}
}
<?php
namespace Drupal\Tests\block_content\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;
/**
* Tests update functions for the Block Content module.
*
* @group block_content
*/
class BlockContentUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles(): void {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz',
];
}
/**
* Tests moving the custom block library to Content.
*
* @see block_content_post_update_move_custom_block_library()
*/
public function testMoveCustomBlockLibraryToContent(): void {
$user = $this->drupalCreateUser(['administer blocks']);
$this->drupalLogin($user);
$this->drupalGet('admin/structure/block/block-content');
$this->assertSession()->statusCodeEquals(200);
$this->drupalGet('admin/content/block-content');
$this->assertSession()->statusCodeEquals(404);
$this->runUpdates();
// Load and initialize the block_content view.
$view = View::load('block_content');
$data = $view->toArray();
// Check that the path, description, and menu options have been updated.
$this->assertEquals('admin/content/block-content', $data['display']['page_1']['display_options']['path']);
$this->assertEquals('Create and edit custom block content.', $data['display']['page_1']['display_options']['menu']['description']);
$this->assertFalse($data['display']['page_1']['display_options']['menu']['expanded']);
$this->assertEquals('system.admin_content', $data['display']['page_1']['display_options']['menu']['parent']);
// Check the new path is accessible.
$user = $this->drupalCreateUser(['administer blocks']);
$this->drupalLogin($user);
$this->drupalGet('admin/content/block-content');
$this->assertSession()->statusCodeEquals(200);
}
/**
* Tests the block_content view isn't updated if the path has been modified.
*
* @see block_content_post_update_move_custom_block_library()
*/
public function testCustomBlockLibraryPathOverridden(): void {
$view = View::load('block_content');
$display =& $view->getDisplay('page_1');
$display['display_options']['path'] = 'some/custom/path';
$view->save();
$this->runUpdates();
$view = View::load('block_content');
$data = $view->toArray();
$this->assertEquals('some/custom/path', $data['display']['page_1']['display_options']['path']);
}
}
......@@ -33,7 +33,7 @@ class BlockContentRedirectTest extends BlockContentTestBase {
*/
public function testRedirectDestination() {
$this->drupalLogin($this->drupalCreateUser(['administer blocks']));
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
// Create a custom block.
$this->clickLink('custom block');
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\block_content\Unit\Menu;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
......@@ -17,7 +18,7 @@ class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase {
*/
protected function setUp(): void {
$this->directoryList = [
'block' => 'core/modules/block',
'system' => 'core/modules/system',
'block_content' => 'core/modules/block_content',
];
parent::setUp();
......@@ -47,9 +48,16 @@ protected function setUp(): void {
->method('listInfo')
->willReturn($themes);
// Add services required for block local tasks.
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->any())
->method('getDefinitions')
->willReturn([]);
$container = new ContainerBuilder();
$container->set('config.factory', $config_factory);
$container->set('theme_handler', $theme_handler);
$container->set('entity_type.manager', $entity_type_manager);
\Drupal::setContainer($container);
}
......@@ -61,7 +69,7 @@ protected function setUp(): void {
public function testBlockContentListLocalTasks($route) {
$this->assertLocalTasks($route, [
0 => [
'block.admin_display',
'system.admin_content',
'entity.block_content.collection',
],
]);
......@@ -72,7 +80,7 @@ public function testBlockContentListLocalTasks($route) {
*/
public function getBlockContentListingRoutes() {
return [
['entity.block_content.collection'],
['entity.block_content.collection', 'system.admin_content'],
];
}
......
......@@ -13,7 +13,7 @@ related:
<h2>{% trans %}What is the block title?{% endtrans %}</h2>
<p>{% trans %}The block title is the heading that is optionally shown to site visitors when the block is placed in a region.{% endtrans %}</p>
<h2>{% trans %}Managing blocks overview{% endtrans %}</h2>
<p>{% trans %}The <em>Block</em> module allows you to place blocks in regions of your installed themes, and configure block settings. The <em>Custom Block</em> module allows you to custom block types and custom blocks. See the related topics listed below for specific tasks.{% endtrans %}</p>
<p>{% trans %}The <em>Block</em> module allows you to place blocks in regions of your installed themes, and configure block settings. The <em>Custom Block</em> module allows you to manage custom block types and custom blocks. See the related topics listed below for specific tasks.{% endtrans %}</p>
<h2>{% trans %}Additional resources{% endtrans %}</h2>
<ul>
<li>{% trans %}<a href="https://www.drupal.org/docs/user_guide/en/blocks-chapter.html">Blocks chapter of the User Guide</a>{% endtrans %}</li>
......
......@@ -6,13 +6,14 @@ related:
- block.place
- block_content.type
---
{% set library_link_text %}{% trans %}Custom block library{% endtrans %}{% endset %}
{% set library_link_text %}{% trans %}Custom blocks{% endtrans %}{% endset %}
{% set library_link = render_var(help_route_link(library_link_text, 'entity.block_content.collection')) %}
<h2>{% trans %}Goal{% endtrans %}</h2>
<p>{% trans %}Create a custom block, which can later be placed on the site.{% endtrans %}</p>
<h2>{% trans %}Steps{% endtrans %}</h2>
<ol>
<li>{% trans %}In the <em>Manage</em> administrative menu, navigate to <em>Structure</em> &gt; <em>Block layout</em> &gt; {{ library_link }}.{% endtrans %}</li>
<li>{% trans %}In the <em>Manage</em> administrative menu, navigate to <em>Content</em>.{% endtrans %}</li>
<li>{% trans %}Open the {{ library_link }} tab.{% endtrans %}</li>
<li>{% trans %}Click <em>Add custom block</em>. If you have more than one custom block type defined on your site, click the name of the type you want to create.{% endtrans %}</li>
<li>{% trans %}Enter a description of your block (to be shown to administrators) and the body text for your block.{% endtrans %}</li>
<li>{% trans %}Click <em>Save</em>.{% endtrans %}</li>
......
......@@ -169,7 +169,7 @@ public function testUpdatedSite() {
$this->drupalGet('admin/structure/block');
$this->assertSession()->pageTextContains('Another block');
$this->assertSession()->pageTextContains('Test block');
$this->drupalGet('admin/structure/block/block-content');
$this->drupalGet('admin/content/block-content');
$this->assertSession()->pageTextContains('Another block');
$this->assertSession()->pageTextContains('Test block');
......
......@@ -103,7 +103,7 @@ public function testBlockContentEntityQueryAccess() {
]);
$this->drupalLogin($account);
$this->drupalGet('/admin/structure/block/block-content');
$this->drupalGet('/admin/content/block-content');
$assert_session = $this->assertSession();
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains($accessible_block->label());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment