Commit a924ab55 authored by Fabiano Sant'Ana's avatar Fabiano Sant'Ana
Browse files

Issue #3086495 by wundo: Remove calls to deprecated functions

parent 656adea9
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\captcha\Form; namespace Drupal\captcha\Form;
use Drupal\captcha\Service\CaptchaService;
use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -12,6 +13,13 @@ use Symfony\Component\HttpFoundation\RequestStack; ...@@ -12,6 +13,13 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/ */
class CaptchaPointForm extends EntityForm { class CaptchaPointForm extends EntityForm {
/**
* The CAPTCHA helper service.
*
* @var \Drupal\captcha\Service\CaptchaService
*/
protected $captchaService;
/** /**
* The request stack. * The request stack.
* *
...@@ -25,8 +33,9 @@ class CaptchaPointForm extends EntityForm { ...@@ -25,8 +33,9 @@ class CaptchaPointForm extends EntityForm {
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* Constructor. * Constructor.
*/ */
public function __construct(RequestStack $request_stack) { public function __construct(RequestStack $request_stack, CaptchaService $captcha_service) {
$this->requestStack = $request_stack; $this->requestStack = $request_stack;
$this->captchaService = $captcha_service;
} }
/** /**
...@@ -39,7 +48,8 @@ class CaptchaPointForm extends EntityForm { ...@@ -39,7 +48,8 @@ class CaptchaPointForm extends EntityForm {
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('request_stack') $container->get('request_stack'),
$container->get('captcha.helper')
); );
} }
...@@ -84,9 +94,8 @@ class CaptchaPointForm extends EntityForm { ...@@ -84,9 +94,8 @@ class CaptchaPointForm extends EntityForm {
'#type' => 'select', '#type' => 'select',
'#title' => $this->t('Challenge type'), '#title' => $this->t('Challenge type'),
'#description' => $this->t('The CAPTCHA type to use for this form.'), '#description' => $this->t('The CAPTCHA type to use for this form.'),
'#default_value' => ($captcha_point->getCaptchaType() ?: $this->config('captcha.settings') '#default_value' => $captcha_point->getCaptchaType() ?: $this->config('captcha.settings')->get('default_challenge'),
->get('default_challenge')), '#options' => $this->captchaService->getAvailableChallengeTypes(),
'#options' => _captcha_available_challenge_types(),
]; ];
return $form; return $form;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\captcha\Form; namespace Drupal\captcha\Form;
use Drupal\captcha\Service\CaptchaService;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
...@@ -22,6 +23,13 @@ class CaptchaSettingsForm extends ConfigFormBase { ...@@ -22,6 +23,13 @@ class CaptchaSettingsForm extends ConfigFormBase {
*/ */
protected $cacheBackend; protected $cacheBackend;
/**
* The CAPTCHA helper service.
*
* @var \Drupal\captcha\Service\CaptchaService
*/
protected $captchaService;
/** /**
* The module handler. * The module handler.
* *
...@@ -39,10 +47,11 @@ class CaptchaSettingsForm extends ConfigFormBase { ...@@ -39,10 +47,11 @@ class CaptchaSettingsForm extends ConfigFormBase {
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* Module handler. * 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); parent::__construct($config_factory);
$this->cacheBackend = $cache_backend; $this->cacheBackend = $cache_backend;
$this->moduleHandler = $moduleHandler; $this->moduleHandler = $moduleHandler;
$this->captchaService = $captcha_service;
} }
/** /**
...@@ -52,7 +61,8 @@ class CaptchaSettingsForm extends ConfigFormBase { ...@@ -52,7 +61,8 @@ class CaptchaSettingsForm extends ConfigFormBase {
return new static( return new static(
$container->get('config.factory'), $container->get('config.factory'),
$container->get('cache.default'), $container->get('cache.default'),
$container->get('module_handler') $container->get('module_handler'),
$container->get('captcha.helper')
); );
} }
...@@ -90,7 +100,7 @@ class CaptchaSettingsForm extends ConfigFormBase { ...@@ -90,7 +100,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
'#type' => 'select', '#type' => 'select',
'#title' => $this->t('Default challenge type'), '#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.'), '#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'), '#default_value' => $config->get('default_challenge'),
]; ];
......
Supports Markdown
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