You are here

public function Webform::addWebformVariant in Webform 6.x

Same name and namespace in other branches
  1. 8.5 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 2894

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;
}