You are here

protected function ReCaptchaV3ActionListBuilder::getCaptchaChallengeTypes in reCAPTCHA v3 8

Get reCaptcha v3 challenge types.

Return value

array All reCaptcha v3 challenge types.

File

src/ReCaptchaV3ActionListBuilder.php, line 51

Class

ReCaptchaV3ActionListBuilder
Provides a listing of reCAPTCHA v3 action entities.

Namespace

Drupal\recaptcha_v3

Code

protected function getCaptchaChallengeTypes() {
  if ($this->challengeTypes === NULL) {
    $this->challengeTypes = \Drupal::service('captcha.helper')
      ->getAvailableChallengeTypes(FALSE);
    $this->challengeTypes = array_filter($this->challengeTypes, static function ($captcha_type) {
      return !(strpos($captcha_type, 'recaptcha_v3') === 0);
    }, ARRAY_FILTER_USE_KEY);
    $default = \Drupal::config('recaptcha_v3.settings')
      ->get('default_challenge');
    $this->challengeTypes['default'] = $this->challengeTypes[$default] ?? $this
      ->t('Default');
  }
  return $this->challengeTypes;
}