Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
b8d150cc
Commit
b8d150cc
authored
Sep 11, 2013
by
webchick
Browse files
Issue
#2035689
by plopesc: Convert user_form_test_current_password() to a Controller.
parent
73050fbb
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/modules/user/tests/modules/user_form_test/lib/Drupal/user_form_test/Form/TestCurrentPassword.php
0 → 100644
View file @
b8d150cc
<?php
/**
* @file
* Contains \Drupal\user_form_test\Form\TestCurrentPassword.
*/
namespace
Drupal\user_form_test\Form
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\user\UserInterface
;
/**
* Provides a current password validation form.
*/
class
TestCurrentPassword
extends
FormBase
{
/**
* {@inheritdoc}
*/
public
function
getFormID
()
{
return
'user_form_test_current_password'
;
}
/**
* {@inheritdoc}
*
* @param \Drupal\user\Entity\UserInterface $user
* The user account.
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
UserInterface
$user
=
NULL
)
{
$form_state
[
'user'
]
=
$user
;
$form
[
'user_form_test_field'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'Test field'
),
'#description'
=>
$this
->
t
(
'A field that would require a correct password to change.'
),
'#required'
=>
TRUE
,
);
$form
[
'current_pass'
]
=
array
(
'#type'
=>
'password'
,
'#title'
=>
$this
->
t
(
'Current password'
),
'#size'
=>
25
,
'#description'
=>
$this
->
t
(
'Enter your current password'
),
);
$form
[
'current_pass_required_values'
]
=
array
(
'#type'
=>
'value'
,
'#value'
=>
array
(
'user_form_test_field'
=>
$this
->
t
(
'Test field'
)),
);
$form
[
'#validate'
][]
=
'user_validate_current_pass'
;
$form
[
'submit'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Test'
),
);
return
$form
;
}
/**
* {@inheritdoc}.
*/
public
function
submitForm
(
array
&
$form
,
array
&
$form_state
)
{
drupal_set_message
(
$this
->
t
(
'The password has been validated and the form submitted successfully.'
));
}
}
core/modules/user/tests/modules/user_form_test/user_form_test.module
View file @
b8d150cc
...
...
@@ -14,51 +14,8 @@ function user_form_test_menu() {
$items
=
array
();
$items
[
'user_form_test_current_password/%user'
]
=
array
(
'title'
=>
'User form test for current password validation'
,
'page callback'
=>
'drupal_get_form'
,
'page arguments'
=>
array
(
'user_form_test_current_password'
,
1
),
'access arguments'
=>
array
(
'administer users'
),
'route_name'
=>
'user_form_test_current_password'
,
'type'
=>
MENU_SUGGESTED_ITEM
,
);
return
$items
;
}
/**
* A test form for user_validate_current_pass().
*/
function
user_form_test_current_password
(
$form
,
&
$form_state
,
$account
)
{
$account
->
user_form_test_field
=
''
;
$form_state
[
'user'
]
=
$account
;
$form
[
'user_form_test_field'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Test field'
),
'#description'
=>
t
(
'A field that would require a correct password to change.'
),
'#required'
=>
TRUE
,
);
$form
[
'current_pass'
]
=
array
(
'#type'
=>
'password'
,
'#title'
=>
t
(
'Current password'
),
'#size'
=>
25
,
'#description'
=>
t
(
'Enter your current password'
),
);
$form
[
'current_pass_required_values'
]
=
array
(
'#type'
=>
'value'
,
'#value'
=>
array
(
'user_form_test_field'
=>
t
(
'Test field'
)),
);
$form
[
'#validate'
][]
=
'user_validate_current_pass'
;
$form
[
'submit'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Test'
),
);
return
$form
;
}
/**
* Submit function for the test form for user_validate_current_pass().
*/
function
user_form_test_current_password_submit
(
$form
,
&
$form_state
)
{
drupal_set_message
(
t
(
'The password has been validated and the form submitted successfully.'
));
}
core/modules/user/tests/modules/user_form_test/user_form_test.routing.yml
0 → 100644
View file @
b8d150cc
user_form_test_current_password
:
pattern
:
'
/user_form_test_current_password/{user}'
defaults
:
_form
:
'
\Drupal\user_form_test\Form\TestCurrentPassword'
requirements
:
_permission
:
'
administer
users'
Write
Preview
Markdown
is supported
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