function BlockContentController::addForm
Same name in other branches
- 9 core/modules/block_content/src/Controller/BlockContentController.php \Drupal\block_content\Controller\BlockContentController::addForm()
- 10 core/modules/block_content/src/Controller/BlockContentController.php \Drupal\block_content\Controller\BlockContentController::addForm()
- 11.x core/modules/block_content/src/Controller/BlockContentController.php \Drupal\block_content\Controller\BlockContentController::addForm()
Presents the custom block creation form.
Parameters
\Drupal\block_content\BlockContentTypeInterface $block_content_type: The custom block type to add.
\Symfony\Component\HttpFoundation\Request $request: The current request object.
Return value
array A form array as expected by \Drupal\Core\Render\RendererInterface::render().
1 call to BlockContentController::addForm()
- BlockContentController::add in core/
modules/ block_content/ src/ Controller/ BlockContentController.php - Displays add custom block links for available types.
1 string reference to 'BlockContentController::addForm'
- block_content.routing.yml in core/
modules/ block_content/ block_content.routing.yml - core/modules/block_content/block_content.routing.yml
File
-
core/
modules/ block_content/ src/ Controller/ BlockContentController.php, line 104
Class
Namespace
Drupal\block_content\ControllerCode
public function addForm(BlockContentTypeInterface $block_content_type, Request $request) {
$block = $this->blockContentStorage
->create([
'type' => $block_content_type->id(),
]);
if (($theme = $request->query
->get('theme')) && in_array($theme, array_keys($this->themeHandler
->listInfo()))) {
// 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 $this->entityFormBuilder()
->getForm($block);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.