You are here

public function BlockContentController::addForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block_content/src/Controller/BlockContentController.php \Drupal\block_content\Controller\BlockContentController::addForm()
  2. 9 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 105

Class

BlockContentController

Namespace

Drupal\block_content\Controller

Code

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