You are here

function honeypot_webform_admin_third_party_settings_form_alter in Webform 8.5

Same name and namespace in other branches
  1. 6.x third_party_settings/webform.honeypot.inc \honeypot_webform_admin_third_party_settings_form_alter()

Implements hook_webform_admin_third_party_settings_form_alter().

File

third_party_settings/webform.honeypot.inc, line 135
Integrates third party settings on the Honeypot module's behalf.

Code

function honeypot_webform_admin_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');
  $honeypot = (int) $third_party_settings_manager
    ->getThirdPartySetting('honeypot', 'honeypot');
  $honeypot_state = \Drupal::config('honeypot.settings')
    ->get('protect_all_forms') ? WEBFORM_HONEYPOT_ENABLED_ALL : WEBFORM_HONEYPOT_NEUTRAL;
  $honeypot_time_limit = (int) \Drupal::config('honeypot.settings')
    ->get('time_limit');
  $time_restriction = (int) $third_party_settings_manager
    ->getThirdPartySetting('honeypot', 'time_restriction');
  $time_restriction_state = $honeypot_time_limit === 0 ? WEBFORM_HONEYPOT_DISABLED_ALL : WEBFORM_HONEYPOT_NEUTRAL;
  _webform_honeypot_form($form, $form_state, $honeypot, $honeypot_state, $time_restriction, $time_restriction_state, t('all webforms'));
}