You are here

public static function WebformEntityHandler::create in Webform Entity Handler 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/WebformHandler/WebformEntityHandler.php \Drupal\webform_entity_handler\Plugin\WebformHandler\WebformEntityHandler::create()

IMPORTANT: Webform handlers are initialized and serialized when they are attached to a webform. Make sure not include any services as a dependency injection that directly connect to the database. This will prevent "LogicException: The database connection is not serializable." exceptions from being thrown when a form is serialized via an Ajax callback and/or form build.

Overrides WebformHandlerBase::create

File

src/Plugin/WebformHandler/WebformEntityHandler.php, line 81

Class

WebformEntityHandler
Create or update an entity with a webform submission values.

Namespace

Drupal\webform_entity_handler\Plugin\WebformHandler

Code

public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
  $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
  $instance
    ->setEntityFieldManager($container
    ->get('entity_field.manager'));
  $instance
    ->setEntityTypeBundleInfo($container
    ->get('entity_type.bundle.info'));
  $instance
    ->setEntityTypeManager($container
    ->get('entity_type.manager'));
  $instance
    ->setWebformElementManager($container
    ->get('plugin.manager.webform.element'));
  $instance
    ->setWebformTokenManager($container
    ->get('webform.token_manager'));
  return $instance;
}