Page callback: Form constructor for the custom block type deletion form.
\Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type: The custom block type to be deleted.
custom_block_type_delete_form_submit()
function custom_block_type_delete_form($form, &$form_state, CustomBlockType $block_type) {
$form_state['custom_block_type'] = $block_type;
$form['id'] = array(
'#type' => '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 = '<p>' . 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(),
)) . '</p>';
$form['description'] = array(
'#markup' => $caption,
);
return $form;
}
return confirm_form($form, $message, 'admin/structure/custom-blocks', t('This action cannot be undone.'), t('Delete'));
}