You are here

public function Webform::addWebformVariant in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Entity/Webform.php \Drupal\webform\Entity\Webform::addWebformVariant()

Saves a webform variant for this webform.

Parameters

\Drupal\webform\Plugin\WebformVariantInterface $variant: The webform variant object.

Return value

string The webform variant ID.

Overrides WebformInterface::addWebformVariant

File

src/Entity/Webform.php, line 2893

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function addWebformVariant(WebformVariantInterface $variant) {
  $variant
    ->setWebform($this);
  $variant_id = $variant
    ->getVariantId();
  $configuration = $variant
    ->getConfiguration();
  $this
    ->getVariants()
    ->addInstanceId($variant_id, $configuration);
  $this
    ->save();
  return $this;
}