You are here

public function PanelsDisplayManager::createDisplay in Panels 8.4

Same name and namespace in other branches
  1. 8.3 src/PanelsDisplayManager.php \Drupal\panels\PanelsDisplayManager::createDisplay()

Create a new panels display.

Parameters

string|\Drupal\Core\Layout\LayoutInterface|NULL $layout: The layout plugin object or plugin id. If omitted, the default Panels layout will be used.

string|\Drupal\panels\Plugin\DisplayBuilder\DisplayBuilderInterface|NULL $builder: The builder object or plugin id. If omitted, the default Panels builder will be used.

Return value

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant

Throws

\Exception If $layout or $builder are of an invalid type.

Overrides PanelsDisplayManagerInterface::createDisplay

File

src/PanelsDisplayManager.php, line 40

Class

PanelsDisplayManager
A service that manages Panels displays.

Namespace

Drupal\panels

Code

public function createDisplay($layout = NULL, $builder = NULL) {
  $display = $this->variantManager
    ->createInstance('panels_variant', []);

  // Set the default builder and layout.
  // @todo: load the defaults from config somewhere.
  $display
    ->setLayout($layout ?: 'layout_onecol');
  $display
    ->setBuilder($builder ?: 'standard');
  return $display;
}