You are here

public function Webform::addWebformHandler in Webform 8.5

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

Saves a webform handler for this webform.

Parameters

\Drupal\webform\Plugin\WebformHandlerInterface $handler: The webform handler object.

Return value

string The webform handler ID.

Overrides WebformInterface::addWebformHandler

File

src/Entity/Webform.php, line 2644

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function addWebformHandler(WebformHandlerInterface $handler) {
  $handler
    ->setWebform($this);
  $handler_id = $handler
    ->getHandlerId();
  $configuration = $handler
    ->getConfiguration();
  $this
    ->getHandlers()
    ->addInstanceId($handler_id, $configuration);
  $this
    ->save();
  $this
    ->resetHandlers();
  $handler
    ->createHandler();
  return $this;
}