Commit a924ab55 authored by wundo's avatar wundo

Issue #3086495 by wundo: Remove calls to deprecated functions

parent 656adea9
......@@ -2,6 +2,7 @@
namespace Drupal\captcha\Form;
use Drupal\captcha\Service\CaptchaService;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -12,6 +13,13 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class CaptchaPointForm extends EntityForm {
/**
* The CAPTCHA helper service.
*
* @var \Drupal\captcha\Service\CaptchaService
*/
protected $captchaService;
/**
* The request stack.
*
......@@ -25,8 +33,9 @@ class CaptchaPointForm extends EntityForm {
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* Constructor.
*/
public function __construct(RequestStack $request_stack) {
public function __construct(RequestStack $request_stack, CaptchaService $captcha_service) {
$this->requestStack = $request_stack;
$this->captchaService = $captcha_service;
}
/**
......@@ -39,7 +48,8 @@ class CaptchaPointForm extends EntityForm {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('request_stack')
$container->get('request_stack'),
$container->get('captcha.helper')
);
}
......@@ -84,9 +94,8 @@ class CaptchaPointForm extends EntityForm {
'#type' => 'select',
'#title' => $this->t('Challenge type'),
'#description' => $this->t('The CAPTCHA type to use for this form.'),
'#default_value' => ($captcha_point->getCaptchaType() ?: $this->config('captcha.settings')
->get('default_challenge')),
'#options' => _captcha_available_challenge_types(),
'#default_value' => $captcha_point->getCaptchaType() ?: $this->config('captcha.settings')->get('default_challenge'),
'#options' => $this->captchaService->getAvailableChallengeTypes(),
];
return $form;
......
......@@ -2,6 +2,7 @@
namespace Drupal\captcha\Form;
use Drupal\captcha\Service\CaptchaService;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
......@@ -22,6 +23,13 @@ class CaptchaSettingsForm extends ConfigFormBase {
*/
protected $cacheBackend;
/**
* The CAPTCHA helper service.
*
* @var \Drupal\captcha\Service\CaptchaService
*/
protected $captchaService;
/**
* The module handler.
*
......@@ -39,10 +47,11 @@ class CaptchaSettingsForm extends ConfigFormBase {
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* Module handler.
*/
public function __construct(ConfigFactoryInterface $config_factory, CacheBackendInterface $cache_backend, ModuleHandlerInterface $moduleHandler) {
public function __construct(ConfigFactoryInterface $config_factory, CacheBackendInterface $cache_backend, ModuleHandlerInterface $moduleHandler, CaptchaService $captcha_service) {
parent::__construct($config_factory);
$this->cacheBackend = $cache_backend;
$this->moduleHandler = $moduleHandler;
$this->captchaService = $captcha_service;
}
/**
......@@ -52,7 +61,8 @@ class CaptchaSettingsForm extends ConfigFormBase {
return new static(
$container->get('config.factory'),
$container->get('cache.default'),
$container->get('module_handler')
$container->get('module_handler'),
$container->get('captcha.helper')
);
}
......@@ -90,7 +100,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
'#type' => 'select',
'#title' => $this->t('Default challenge type'),
'#description' => $this->t('Select the default challenge type for CAPTCHAs. This can be overridden for each form if desired.'),
'#options' => _captcha_available_challenge_types(FALSE),
'#options' => $this->captchaService->getAvailableChallengeTypes(FALSE),
'#default_value' => $config->get('default_challenge'),
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment