Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
captcha
Commits
a924ab55
Commit
a924ab55
authored
Oct 08, 2019
by
Fabiano Sant'Ana
Browse files
Issue #3086495 by wundo: Remove calls to deprecated functions
parent
656adea9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Form/CaptchaPointForm.php
View file @
a924ab55
...
@@ -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
;
...
...
src/Form/CaptchaSettingsForm.php
View file @
a924ab55
...
@@ -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_a
vailable
_c
hallenge
_t
ypes
(
FALSE
),
'#options'
=>
$this
->
captchaService
->
getA
vailable
C
hallenge
T
ypes
(
FALSE
),
'#default_value'
=>
$config
->
get
(
'default_challenge'
),
'#default_value'
=>
$config
->
get
(
'default_challenge'
),
];
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment