You are here

public function PanelsDisplayVariant::setLayout in Panels 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/DisplayVariant/PanelsDisplayVariant.php \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant::setLayout()

Assigns the layout plugin to this variant.

Parameters

string|\Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout: The layout plugin object or plugin id.

array $layout_settings: The layout configuration.

Return value

$this

Throws

\Exception If $layout isn't a string or LayoutInterface object.

File

src/Plugin/DisplayVariant/PanelsDisplayVariant.php, line 204

Class

PanelsDisplayVariant
Provides a display variant that simply contains blocks.

Namespace

Drupal\panels\Plugin\DisplayVariant

Code

public function setLayout($layout, array $layout_settings = []) {
  if ($layout instanceof LayoutInterface) {
    $this->layout = $layout;
    $this->configuration['layout'] = $layout
      ->getPluginId();
    $this->configuration['layout_settings'] = $layout_settings;
  }
  elseif (is_string($layout)) {
    $this->layout = NULL;
    $this->configuration['layout'] = $layout;
    $this->configuration['layout_settings'] = $layout_settings;
  }
  else {
    throw new \Exception("Layout must be a string or LayoutInterface object");
  }
  return $this;
}