public function PanelsDisplayVariant::setPattern in Panels 8.4
Same name and namespace in other branches
- 8.3 src/Plugin/DisplayVariant/PanelsDisplayVariant.php \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant::setPattern()
Assign the pattern for panels content operations and default contexts.
Parameters
mixed string|\Drupal\panels\Plugin\PanelsPattern\PanelsPatternInterface $pattern:
Return value
$this
Throws
\Exception If $pattern isn't a string or PanelsPatternInterface object.
File
- src/
Plugin/ DisplayVariant/ PanelsDisplayVariant.php, line 246
Class
- PanelsDisplayVariant
- Provides a display variant that simply contains blocks.
Namespace
Drupal\panels\Plugin\DisplayVariantCode
public function setPattern($pattern) {
if ($pattern instanceof PanelsPatternInterface) {
$this->pattern = $pattern;
$this->configuration['pattern'] = $pattern
->getPluginId();
}
elseif (is_string($pattern)) {
$this->pattern = NULL;
$this->configuration['pattern'] = $pattern;
}
else {
throw new \Exception("Pattern must be a string or PanelsPatternInterface object");
}
return $this;
}