You are here

public function Webform::addWebformHandler in Webform 6.x

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

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