Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By jrockowitz on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x-5.x
Introduced in version:
8.x-5.0-rc19
Issue links:
Description:
Added hook_webform_handler_invoke_alter() and hook_webform_handler_invoke_METHOD_NAME_alter()
/**
* Act on a webform handler when a method is invoked.
*
* Allows module developers to implement custom logic that can executed before
* any webform handler method is invoked.
*
* This hook can be used to…
* - Conditionally enable or disable a handler.
* - Alter a handler's configuration.
* - Preprocess submission data being passed to a webform handler.
*
* @param \Drupal\webform\Plugin\WebformHandlerInterface $handler
* A webform handler attached to a webform
* @param $method_name
* The invoked method name converted to snake case.
* @param array $args
* Argument being passed to the handler's method.
*
* @see \Drupal\webform\Plugin\WebformHandlerInterface
*/
function webform_test_handler_invoke_alter_webform_handler_invoke_alter(\Drupal\webform\Plugin\WebformHandlerInterface $handler, $method_name, array &$args) {
$webform = $handler->getWebform();
$webform_submission = $handler->getWebformSubmission();
$webform_id = $handler->getWebform()->id();
$handler_id = $handler->getHandlerId();
$state = $webform_submission->getState();
}
/**
* Act on a webform handler when a specific method is invoked.
*
* Allows module developers to implement custom logic that can executed before
* a specified webform handler method is invoked.
*
* This hook can be used to…
* - Conditionally enable or disable a handler.
* - Alter a handler's configuration.
* - Preprocess submission data being passed to a webform handler.
*
* @param \Drupal\webform\Plugin\WebformHandlerInterface $handler
* A webform handler attached to a webform
* @param array $args
* Argument being passed to the handler's method.
*
* @see \Drupal\webform\Plugin\WebformHandlerInterface
*/
function hook_webform_handler_invoke_METHOD_NAME_alter(\Drupal\webform\Plugin\WebformHandlerInterface $handler, array &$args) {
$webform = $handler->getWebform();
$webform_submission = $handler->getWebformSubmission();
$webform_id = $handler->getWebform()->id();
$handler_id = $handler->getHandlerId();
$state = $webform_submission->getState();
}
Impacts:
Module developers