diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index a54aa25..4b206c9 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -98,6 +98,9 @@ function custom_block_menu() { ); $items['block/%custom_block/delete'] = array( 'title' => 'Delete', + 'weight' => 1, + 'type' => MENU_LOCAL_TASK, + 'context' => MENU_CONTEXT_INLINE, 'route_name' => 'custom_block_delete', ); return $items; diff --git a/core/modules/block/custom_block/custom_block.routing.yml b/core/modules/block/custom_block/custom_block.routing.yml index c0e8785..41c1446 100644 --- a/core/modules/block/custom_block/custom_block.routing.yml +++ b/core/modules/block/custom_block/custom_block.routing.yml @@ -15,7 +15,10 @@ custom_block_add_page: custom_block_delete: pattern: '/block/{custom_block}/delete' + options: + converters: + custom_block: 'custom_block' defaults: _form: '\Drupal\custom_block\Form\CustomBlockDeleteForm' requirements: - _permission: 'administer blocks' + _entity_access: 'custom_block.view' diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php index 3c97589..462ac79 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php @@ -18,7 +18,7 @@ class CustomBlockDeleteForm extends ConfirmFormBase { /** * The block being deleted. * - * @var \Drupal\block\Plugin\Core\Entity\CustomBlock + * @var \Drupal\custom_block\Plugin\Core\Entity\CustomBlock. */ protected $block; @@ -51,13 +51,13 @@ protected function getConfirmText() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} * * @param \Drupal\custom_block\Plugin\Core\Entity\CustomBlock $block * The block instance. */ - public function buildForm(array $form, array &$form_state, Block $block = null) { - $this->block = $block; + public function buildForm(array $form, array &$form_state, CustomBlock $custom_block = NULL) { + $this->block = $custom_block; return parent::buildForm($form, $form_state); } @@ -65,6 +65,7 @@ public function buildForm(array $form, array &$form_state, Block $block = null) * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { + // @todo Delete all configured instances of the block. $this->block->delete(); drupal_set_message(t('The block %name has been removed.', array('%name' => $this->block->label()))); $form_state['redirect'] = 'admin/structure/block';