diff --git a/core/modules/block_content/block_content.links.action.yml b/core/modules/block_content/block_content.links.action.yml index 4772a6f..b0900a6 100644 --- a/core/modules/block_content/block_content.links.action.yml +++ b/core/modules/block_content/block_content.links.action.yml @@ -8,6 +8,4 @@ block_content_add_action: route_name: block_content.add_page title: 'Add custom block' appears_on: - - block.admin_library - entity.block_content.collection - class: \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction diff --git a/core/modules/block_content/block_content.links.menu.yml b/core/modules/block_content/block_content.links.menu.yml index 03209f9..26fb0a1 100644 --- a/core/modules/block_content/block_content.links.menu.yml +++ b/core/modules/block_content/block_content.links.menu.yml @@ -1,5 +1,10 @@ +entity.block_content.collection: + title: 'Custom blocks' + route_name: entity.block_content.collection + parent: system.admin_content + description: 'Create and manage custom blocks that can be placed in theme regions.' entity.block_content_type.collection: - title: Block types + title: 'Block types' route_name: entity.block_content_type.collection parent: system.admin_structure - description: 'List and edit custom block types.' + description: 'Manage form and display settings for custom blocks.' diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index 5a8c222..e88e60f 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -18,22 +18,22 @@ function block_content_help($route_name, RouteMatchInterface $route_match) { $field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#'; $output = ''; $output .= '
' . t('The Custom Block module allows you to create custom block types and content-containing blocks, and provides a page listing all of them. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', array('!block-list' => \Drupal::url('entity.block_content.collection'), '!block-content' => \Drupal::url('entity.block_content.collection'), '!field-help' => \Drupal::url('help.page', array('name' => 'field')), '!blocks' => \Drupal::url('help.page', array('name' => 'block')), '!online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '
'; + $output .= '' . t('The Custom Block module allows you to create custom block types and block content based on those types. Once created, these custom blocks can be placed in regions just like blocks provided by other modules. For more information, see the online documentation for the Custom Block module.', array('!block-types' => \Drupal::url('entity.block_content_type.collection'), '!block-list' => \Drupal::url('entity.block_content.collection'), '!online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '
'; $output .= '' . t('Blocks belong to block types, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', array('!types' => \Drupal::url('entity.block_content_type.collection'), '!blocks' => \Drupal::url('block.admin_display'))) . '
'; + $output = '' . t('Every custom block is based on a block type, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', array('!types' => \Drupal::url('entity.block_content_type.collection'), '!blocks' => \Drupal::url('block.admin_display'))) . '
'; return $output; case 'entity.block_content_type.collection': - $output = '' . t('Each block type has its own fields and display settings. Create blocks of each type on the Custom blocks page.', array('!block-list' => \Drupal::url('entity.block_content.collection'))) . '
'; + $output = '' . t('After creating a block type, you can create a block based on it from the Block content page. Each block type has its own fields and display settings.', array('!block-list' => \Drupal::url('entity.block_content.collection'))) . '
'; return $output; } diff --git a/core/modules/block_content/block_content.routing.yml b/core/modules/block_content/block_content.routing.yml index 957349d..6752a2e 100644 --- a/core/modules/block_content/block_content.routing.yml +++ b/core/modules/block_content/block_content.routing.yml @@ -30,7 +30,7 @@ entity.block_content_type.delete_form: path: '/admin/structure/block-content/manage/{block_content_type}/delete' defaults: _entity_form: 'block_content_type.delete' - _title: 'Delete' + _title: 'Delete block type' requirements: _entity_access: 'block_content_type.delete' options: @@ -39,6 +39,7 @@ entity.block_content_type.delete_form: entity.block_content.canonical: path: '/block/{block_content}' defaults: + _title_callback: '\Drupal\block_content\Controller\BlockContentController::blockContentTitle' _entity_form: 'block_content.edit' options: _admin_route: TRUE @@ -68,7 +69,7 @@ block_content.type_add: path: '/admin/structure/block-content/add' defaults: _entity_form: 'block_content_type.add' - _title: 'Add' + _title: 'Add block type' requirements: _permission: 'administer blocks' @@ -76,7 +77,7 @@ entity.block_content_type.edit_form: path: '/admin/structure/block-content/manage/{block_content_type}' defaults: _entity_form: 'block_content_type.edit' - _title: 'Edit' + _title: 'Edit block type' requirements: _entity_access: 'block_content_type.update' diff --git a/core/modules/block_content/config/optional/views.view.block_content.yml b/core/modules/block_content/config/optional/views.view.block_content.yml index 9ab5b83..2ed048a 100644 --- a/core/modules/block_content/config/optional/views.view.block_content.yml +++ b/core/modules/block_content/config/optional/views.view.block_content.yml @@ -163,7 +163,7 @@ display: click_sort_column: value type: string settings: - link_to_entity: true + link_to_entity: false group_column: value group_columns: { } group_rows: true diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index ec267cc..53c8723 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -182,11 +182,11 @@ public function save(array $form, FormStateInterface $form_state) { $context = array('@type' => $block->bundle(), '%info' => $block->label()); $logger = $this->logger('block_content'); $block_type = $this->blockContentTypeStorage->load($block->bundle()); - $t_args = array('@type' => $block_type->label(), '%info' => $block->label()); + $t_args = array('@type' => $block_type->label(), '%info' => $block->label(), '@layout-url' => \Drupal::url('block.admin_display')); if ($insert) { $logger->notice('@type: added %info.', $context); - drupal_set_message($this->t('@type %info has been created.', $t_args)); + drupal_set_message($this->t('@type %info has been created. Visit the Block layout page to add it to a region.', $t_args)); } else { $logger->notice('@type: updated %info.', $context); @@ -194,23 +194,7 @@ public function save(array $form, FormStateInterface $form_state) { } if ($block->id()) { - $form_state->setValue('id', $block->id()); - $form_state->set('id', $block->id()); - if ($insert) { - if (!$theme = $block->getTheme()) { - $theme = $this->config('system.theme')->get('default'); - } - $form_state->setRedirect( - 'block.admin_add', - array( - 'plugin_id' => 'block_content:' . $block->uuid(), - 'theme' => $theme, - ) - ); - } - else { - $form_state->setRedirectUrl($block->urlInfo('collection')); - } + $form_state->setRedirectUrl($block->urlInfo('collection')); } else { // In the unlikely case something went wrong on save, the block will be diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php index f712367..f9874fc 100644 --- a/core/modules/block_content/src/Controller/BlockContentController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -7,10 +7,11 @@ namespace Drupal\block_content\Controller; +use Drupal\block_content\BlockContentInterface; +use Drupal\block_content\BlockContentTypeInterface; use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\block_content\BlockContentTypeInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -120,6 +121,19 @@ public function addForm(BlockContentTypeInterface $block_content_type, Request $ } /** + * A title callback for block content entities. + * + * @param \Drupal\block_content\BlockContentInterface $block_content + * The current custom block. + * + * @return string + * The title of the custom block. + */ + public function blockContentTitle(BlockContentInterface $block_content) { + return $this->entityManager()->getTranslationFromContext($block_content)->label(); + } + + /** * Provides the page title for this controller. * * @param \Drupal\block_content\BlockContentTypeInterface $block_content_type diff --git a/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php deleted file mode 100644 index 62e0c3c..0000000 --- a/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php +++ /dev/null @@ -1,36 +0,0 @@ -getParameter('theme')) { - $options['query']['theme'] = $theme; - } - // Adds a destination on custom block listing. - if ($route_match->getRouteName() == 'entity.block_content.collection') { - $options['query']['destination'] = $this->url('