diff --git a/core/modules/block/custom_block/custom_block.admin.inc b/core/modules/block/custom_block/custom_block.admin.inc deleted file mode 100644 index 57351ea..0000000 --- a/core/modules/block/custom_block/custom_block.admin.inc +++ /dev/null @@ -1,58 +0,0 @@ - 'value', - '#value' => $block_type->id(), - ); - - $message = t('Are you sure you want to delete %label?', array('%label' => $block_type->label())); - - $blocks = Drupal::entityQuery('custom_block')->condition('type', $block_type->id())->execute(); - if (!empty($blocks)) { - drupal_set_title($message, PASS_THROUGH); - $caption = '

' . format_plural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $block_type->label())) . '

'; - $form['description'] = array('#markup' => $caption); - return $form; - } - - return confirm_form( - $form, - $message, - 'admin/structure/custom-blocks', - t('This action cannot be undone.'), - t('Delete') - ); -} - -/** - * Form submission handler for custom_block_type_delete_form(). - */ -function custom_block_type_delete_form_submit($form, &$form_state) { - $block_type = $form_state['custom_block_type']; - $block_type->delete(); - - drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $block_type->label()))); - watchdog('custom_block', 'Custom block type %label has been deleted.', array('%label' => $block_type->label()), WATCHDOG_NOTICE); - - $form_state['redirect'] = 'admin/structure/custom-blocks'; -} diff --git a/core/modules/block/custom_block/custom_block.routing.yml b/core/modules/block/custom_block/custom_block.routing.yml index e256fd7..02bad13 100644 --- a/core/modules/block/custom_block/custom_block.routing.yml +++ b/core/modules/block/custom_block/custom_block.routing.yml @@ -23,6 +23,8 @@ custom_block_type_delete: pattern: '/admin/structure/custom-blocks/manage/{custom_block_type}/delete' defaults: _entity_form: 'custom_block_type.delete' + requirements: + _entity_access: 'custom_block_type.delete' custom_block_edit: pattern: '/block/{custom_block}' @@ -44,4 +46,4 @@ custom_block_type_edit: defaults: _entity_form: 'custom_block_type.edit' requirements: - _permission: 'administer blocks' + _entity_access: 'custom_block_type.update' diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php index 2404ede..6bc0f4d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php @@ -26,9 +26,9 @@ * "access" = "Drupal\custom_block\CustomBlockAccessController", * "render" = "Drupal\custom_block\CustomBlockRenderController", * "form" = { - * "default" = "Drupal\custom_block\CustomBlockTypeFormController", * "add" = "Drupal\custom_block\CustomBlockFormController", - * "edit" = "Drupal\custom_block\CustomBlockFormController" + * "edit" = "Drupal\custom_block\CustomBlockFormController", + * "default" = "Drupal\custom_block\CustomBlockFormController" * }, * "translation" = "Drupal\custom_block\CustomBlockTranslationController" * }, diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php index 69da7b1..685e370 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php @@ -24,9 +24,10 @@ * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController", * "access" = "Drupal\custom_block\CustomBlockTypeAccessController", * "form" = { - * "delete" = "Drupal\custom_block\Form\CustomBlockTypeDeleteForm", + * "default" = "Drupal\custom_block\CustomBlockTypeFormController", * "add" = "Drupal\custom_block\CustomBlockTypeFormController", - * "edit" = "Drupal\custom_block\CustomBlockTypeFormController" + * "edit" = "Drupal\custom_block\CustomBlockTypeFormController", + * "delete" = "Drupal\custom_block\Form\CustomBlockTypeDeleteForm" * }, * "list" = "Drupal\custom_block\CustomBlockTypeListController" * },