Page callback: Presents the custom block creation form.
Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type: The custom block type to add.
array A form array as expected by drupal_render().
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);
}