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
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -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.'
+2 −2
Original line number Diff line number Diff line
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
+3 −7
Original line number Diff line number Diff line
@@ -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;

  }
}

+28 −0
Original line number Diff line number Diff line
@@ -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();
}
+13 −2
Original line number Diff line number Diff line
@@ -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'
Loading