public function Page::addVariant in Page Manager 8.4
Same name and namespace in other branches
- 8 src/Entity/Page.php \Drupal\page_manager\Entity\Page::addVariant()
Adds a variant to this page.
Parameters
\Drupal\page_manager\PageVariantInterface $variant: A page variant entity.
Return value
$this
Overrides PageInterface::addVariant
File
- src/
Entity/ Page.php, line 380
Class
- Page
- Defines a Page entity class.
Namespace
Drupal\page_manager\EntityCode
public function addVariant(PageVariantInterface $variant) {
// If variants hasn't been initialized, we initialize it before adding the
// new variant.
if ($this->variants === NULL) {
$this
->getVariants();
}
$this->variants[$variant
->id()] = $variant;
$this
->sortVariants();
return $this;
}