function custom_block_type_delete_form

Page callback: Form constructor for the custom block type deletion form.

Parameters

\Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type: The custom block type to be deleted.

See also

custom_block_menu()

custom_block_type_delete_form_submit()

Related topics

1 string reference to 'custom_block_type_delete_form'
custom_block_menu in drupal/core/modules/block/custom_block/custom_block.module
Implements hook_menu().

File

drupal/core/modules/block/custom_block/custom_block.admin.inc, line 49
Admin page callbacks for the custom block module.

Code

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'));
}