You are here

public function CaptchaQuestionsSettingsForm::captchaQuestionsGetFormIds in Captcha Questions 8

Helper function to make a list of candidates of form ids.

1 call to CaptchaQuestionsSettingsForm::captchaQuestionsGetFormIds()
CaptchaQuestionsSettingsForm::buildForm in src/Form/CaptchaQuestionsSettingsForm.php
Form constructor.

File

src/Form/CaptchaQuestionsSettingsForm.php, line 298

Class

CaptchaQuestionsSettingsForm
Displays the captcha_questions settings form.

Namespace

Drupal\captcha_questions\Form

Code

public function captchaQuestionsGetFormIds() {

  // Some form nids that might exist on the site.
  $form_ids = [
    'contact_site_form',
    'contact_personal_form',
    'user_register_form',
    'user_pass',
    'user_login_form',
    'user_login_block',
    'forum_node_form',
  ];

  // Fetching form ids for all node types.
  foreach (node_type_get_names() as $type => $name) {
    $form_ids[] = 'comment_node_' . $type . '_form';
  }

  // Fetching webform form_ids.
  if ($this->moduleHandler
    ->moduleExists('webform')) {
    $webform_forms = $this
      ->captchaQuestionsGetWebforms();
    foreach ($webform_forms as $webform_id => $webform) {
      $form_ids[] = $webform_id;
    }
  }

  // Adding custom form_ids. This will add all selected forms.
  $custom_form_ids = $this
    ->config('captcha_questions.settings')
    ->get('captcha_questions_form_ids');
  foreach ($custom_form_ids as $custom_form_id) {
    $form_ids[] = $custom_form_id;
  }

  // Removing possible duplicates from last step.
  $form_ids = array_unique($form_ids);
  return $form_ids;
}