function honeypot_webform_third_party_settings_form_alter in Webform 8.5
Same name and namespace in other branches
- 6.x third_party_settings/webform.honeypot.inc \honeypot_webform_third_party_settings_form_alter()
Implements hook_webform_third_party_settings_form_alter().
File
- third_party_settings/
webform.honeypot.inc, line 160 - Integrates third party settings on the Honeypot module's behalf.
Code
function honeypot_webform_third_party_settings_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager */
$third_party_settings_manager = \Drupal::service('webform.third_party_settings_manager');
/** @var \Drupal\webform\WebformInterface $webform */
$webform = $form_state
->getFormObject()
->getEntity();
$honeypot = (int) $webform
->getThirdPartySetting('honeypot', 'honeypot');
if (\Drupal::config('honeypot.settings')
->get('protect_all_forms')) {
$honeypot_state = WEBFORM_HONEYPOT_ENABLED_ALL;
}
elseif ($third_party_settings_manager
->getThirdPartySetting('honeypot', 'honeypot')) {
$honeypot_state = WEBFORM_HONEYPOT_ENABLED_WEBFORM;
}
else {
$honeypot_state = WEBFORM_HONEYPOT_NEUTRAL;
}
$time_restriction = (int) $webform
->getThirdPartySetting('honeypot', 'time_restriction');
$honeypot_time_limit = (int) \Drupal::config('honeypot.settings')
->get('time_limit');
if ($honeypot_time_limit === 0) {
$time_restriction_state = WEBFORM_HONEYPOT_DISABLED_ALL;
}
elseif ($third_party_settings_manager
->getThirdPartySetting('honeypot', 'time_restriction')) {
$time_restriction_state = WEBFORM_HONEYPOT_ENABLED_WEBFORM;
}
else {
$time_restriction_state = WEBFORM_HONEYPOT_NEUTRAL;
}
_webform_honeypot_form($form, $form_state, $honeypot, $honeypot_state, $time_restriction, $time_restriction_state, t('@label webform', [
'@label' => $webform
->label(),
]));
}