Completed
Pull Request — master (#40)
by
unknown
02:05
created

ChangePasswordFormFields::handle()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 27
nc 1
nop 1
1
<?php namespace Anomaly\UsersModule\User\Password;
2
3
/**
4
 * Class ForgotPasswordFormFields
5
 *
6
 * @link          http://pyrocms.com/
7
 * @author        PyroCMS, Inc. <[email protected]>
8
 * @author        Ryan Thompson <[email protected]>
9
 */
10
class ChangePasswordFormFields
11
{
12
13
    /**
14
     * Handle the fields.
15
     *
16
     * @param ChangePasswordFormBuilder $builder
17
     */
18
    public function handle(ChangePasswordFormBuilder $builder)
19
    {
20
        $builder->setFields(
21
            [
22
                'password_old' => [
23
                    'type' => 'anomaly.field_type.text',
24
                    'label' => 'anomaly.module.users::field.password_old.name',
25
                    'config' => [
26
                        'type' => 'password',
27
                    ],
28
                    'required' => true,
29
                    'rules' => [
30
                        'required|valid_password_old',
31
                    ],
32
                    'validators' => [
33
                        'valid_password_old' => [
34
                            'handler' => 'Anomaly\UsersModule\User\Validation\ValidateCurrentPassword@handle',
35
                            'message' => 'anomaly.module.users::message.invalid_password_old',
36
                        ],
37
                    ],
38
                ],
39
                'password_new' => [
40
                    'type' => 'anomaly.field_type.text',
41
                    'label' => 'anomaly.module.users::field.password_new.name',
42
                    'config' => [
43
                        'type' => 'password',
44
                    ],
45
                    'required' => true,
46
                    'rules' => [
47
                        'confirmed',
48
                    ],
49
                ],
50
                'password_new_confirmation' => [
51
                    'type' => 'anomaly.field_type.text',
52
                    'label' => 'anomaly.module.users::field.password_new.name',
53
                    'config' => [
54
                        'type' => 'password',
55
                    ],
56
                ],
57
            ]
58
        );
59
    }
60
}
61