diff --git a/core/modules/block/custom_block/custom_block.admin.inc b/core/modules/block/custom_block/custom_block.admin.inc index 0a31891..0a8c926 100644 --- a/core/modules/block/custom_block/custom_block.admin.inc +++ b/core/modules/block/custom_block/custom_block.admin.inc @@ -20,34 +20,6 @@ function custom_block_type_list() { } /** - * Page callback: Presents the custom block type creation form. - * - * @return array - * A form array as expected by drupal_render(). - * - * @see custom_block_menu() - */ -function custom_block_type_add() { - $block_type = entity_create('custom_block_type', array()); - return entity_get_form($block_type); -} - -/** - * Page callback: Presents the custom block type edit form. - * - * @param \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type - * The custom block type to edit. - * - * @return array - * A form array as expected by drupal_render(). - * - * @see custom_block_menu() - */ -function custom_block_type_edit(CustomBlockType $block_type) { - return entity_get_form($block_type); -} - -/** * Page callback: Form constructor for the custom block type deletion form. * * @param \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index 1bcf414..2e41f23 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -42,20 +42,13 @@ function custom_block_menu() { ); $items['admin/structure/custom-blocks/add'] = array( 'title' => 'Add custom block type', - 'page callback' => 'custom_block_type_add', - 'access arguments' => array('administer blocks'), 'type' => MENU_LOCAL_ACTION, 'weight' => 1, - 'file' => 'custom_block.admin.inc', + 'route_name' => 'custom_block_type_add', ); $items['admin/structure/custom-blocks/manage/%custom_block_type'] = array( 'title' => 'Edit custom block type', - 'title callback' => 'entity_page_label', - 'title arguments' => array(4), - 'page callback' => 'custom_block_type_edit', - 'page arguments' => array(4), - 'access arguments' => array('administer blocks'), - 'file' => 'custom_block.admin.inc', + 'route_name' => 'custom_block_type_edit', ); $items['admin/structure/custom-blocks/manage/%custom_block_type/edit'] = array( 'title' => 'Edit', @@ -88,11 +81,7 @@ function custom_block_menu() { // There has to be a base-item in order for contextual links to work. $items['block/%custom_block'] = array( 'title' => 'Edit', - 'page callback' => 'custom_block_edit', - 'page arguments' => array(1), - 'access callback' => 'entity_page_access', - 'access arguments' => array(1, 'update'), - 'file' => 'custom_block.pages.inc', + 'route_name' => 'custom_block_edit', ); $items['block/%custom_block/edit'] = array( 'title' => 'Edit', diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index 9c802c4..05df42a 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -66,22 +66,6 @@ function custom_block_add(CustomBlockType $block_type) { } /** - * Page callback: Presents the custom block edit form. - * - * @param Drupal\custom_block\Plugin\Core\Entity\CustomBlock $block - * The custom block to edit. - * - * @return array - * A form array as expected by drupal_render(). - * - * @see custom_block_menu() - */ -function custom_block_edit(CustomBlock $block) { - drupal_set_title(t('Edit custom block %label', array('%label' => $block->label())), PASS_THROUGH); - return entity_get_form($block); -} - -/** * Page callback: Form constructor for the custom block deletion form. * * @param Drupal\custom_block\Plugin\Core\Entity\CustomBlock $block diff --git a/core/modules/block/custom_block/custom_block.routing.yml b/core/modules/block/custom_block/custom_block.routing.yml index ed4ab92..c6bd540 100644 --- a/core/modules/block/custom_block/custom_block.routing.yml +++ b/core/modules/block/custom_block/custom_block.routing.yml @@ -4,3 +4,21 @@ custom_block_add_page: _content: 'Drupal\custom_block\Controller\CustomBlockController::add' requirements: _permission: 'administer blocks' +custom_block_type_add + pattern: admin/structure/custom-blocks/add + defaults: + _entity_form: 'custom_block_type.default' + requirements: + _permission: 'administer blocks' +custom_block_type_edit + pattern: admin/structure/custom-blocks/manage/{custom_block_type} + defaults: + _entity_form: 'custom_block_type.default' + requirements: + _permission: 'administer blocks' +custom_block_edit + pattern: block/{custom_block} + defaults: + _entity_form: 'custom_block.default' + requirements: + _entity_access: 'custom_block.update' diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php index 1a09dbf..30518b1 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php @@ -42,6 +42,11 @@ protected function prepareEntity() { */ public function form(array $form, array &$form_state) { $block = $this->entity; + + if ($block->label()) { + // @todo Remove this once https://drupal.org/node/1981644 is in. + drupal_set_title(t('Edit %label', array('%label' => $block_type->label()))); + } // Override the default CSS class name, since the user-defined custom block // type name in 'TYPE-block-form' potentially clashes with third-party class // names. diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index 6e5de33..2957e72 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -21,6 +21,11 @@ public function form(array $form, array &$form_state) { $form = parent::form($form, $form_state); $block_type = $this->entity; + + if ($block_type->label()) { + // @todo Remove this once https://drupal.org/node/1981644 is in. + drupal_set_title(t('Edit %label', array('%label' => $block_type->label()))); + } $form['label'] = array( '#type' => 'textfield', '#title' => t('Label'),