You are here

public function PageManagerController::addPageVariantEntityForm in Page Manager 8

Same name and namespace in other branches
  1. 8.4 page_manager_ui/src/Controller/PageManagerController.php \Drupal\page_manager_ui\Controller\PageManagerController::addPageVariantEntityForm()

Build the page variant entity add form.

Parameters

\Drupal\page_manager\PageInterface $page: The page this page variant belongs to.

string $variant_plugin_id: The variant plugin ID.

Return value

array The page variant entity add form.

File

page_manager_ui/src/Controller/PageManagerController.php, line 374
Contains \Drupal\page_manager_ui\Controller\PageManagerController.

Class

PageManagerController
Provides route controllers for Page Manager.

Namespace

Drupal\page_manager_ui\Controller

Code

public function addPageVariantEntityForm(PageInterface $page, $variant_plugin_id) {

  // Create a page variant entity.
  $entity = $this
    ->entityTypeManager()
    ->getStorage('page_variant')
    ->create([
    'page' => $page
      ->id(),
    'variant' => $variant_plugin_id,
  ]);
  return $this
    ->entityFormBuilder()
    ->getForm($entity, 'add');
}