function custom_block_add

Page callback: Presents the custom block creation form.

Parameters

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

Return value

array A form array as expected by drupal_render().

See also

custom_block_menu()

1 call to custom_block_add()
1 string reference to 'custom_block_add'

File

drupal/core/modules/block/custom_block/custom_block.pages.inc, line 43
Provides page callbacks for custom blocks.

Code

function custom_block_add(CustomBlockType $block_type) {
  drupal_set_title(t('Add %type custom block', array(
    '%type' => $block_type
      ->label(),
  )), PASS_THROUGH);
  $block = entity_create('custom_block', array(
    'type' => $block_type
      ->id(),
  ));
  $options = array();
  $request = drupal_container()
    ->get('request');
  if (($theme = $request->attributes
    ->get('theme')) && in_array($theme, array_keys(list_themes()))) {

    // We have navigated to this page from the block library and will keep track
    // of the theme for redirecting the user to the configuration page for the
    // newly created block in the given theme.
    $block
      ->setTheme($theme);
  }
  return entity_get_form($block);
}