You are here

function _random_captcha_type_get_all_types in CAPTCHA Pack 8

Same name and namespace in other branches
  1. 5 random_captcha_type/random_captcha_type.module \_random_captcha_type_get_all_types()
  2. 6 random_captcha_type/random_captcha_type.inc \_random_captcha_type_get_all_types()
  3. 7 random_captcha_type/random_captcha_type.module \_random_captcha_type_get_all_types()

Function for getting all the possible CAPTCHA types to switch between.

For use as #options entry of a checkboxes widget.

2 calls to _random_captcha_type_get_all_types()
RandomCaptchaTypeSettingsForm::buildForm in random_captcha_type/src/Form/RandomCaptchaTypeSettingsForm.php
Form constructor.
_random_captcha_type_get_enabled_types in random_captcha_type/random_captcha_type.module
Function for getting the enabled CAPTCHA types.

File

random_captcha_type/random_captcha_type.module, line 63
Contains general functionality of the module.

Code

function _random_captcha_type_get_all_types() {
  $captcha_types = [];
  foreach (\Drupal::moduleHandler()
    ->getImplementations('captcha') as $module) {

    // Skip random_captcha_type module.
    if ($module == 'random_captcha_type') {
      continue;
    }

    // Get available  types.
    $result = \Drupal::moduleHandler()
      ->invoke($module, 'captcha', [
      'list',
    ]);
    if (is_array($result)) {
      foreach ($result as $type) {
        $captcha_types["{$module}/{$type}"] = "{$type} ({$module})";
      }
    }
  }
  return $captcha_types;
}