ChangePasswordType::setDefaultOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style introduced by
File has mixed line endings; this may cause incorrect results
Loading history...
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
namespace Eccube\Form\Type\Admin;
25
26
use Symfony\Component\Form\AbstractType;
27
use Symfony\Component\Form\FormBuilderInterface;
28
use Symfony\Component\Form\FormError;
29
use Symfony\Component\Form\FormEvents;
30
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
31
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
32
use Symfony\Component\Validator\Constraints as Assert;
33
34
class ChangePasswordType extends AbstractType
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
35
{
36
    private $app;
37
38 663
    public function __construct($app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
39
    {
40 663
        $this->app = $app;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 3
    public function buildForm(FormBuilderInterface $builder, array $options)
47
    {
48 3
        $app = $this->app;
49
        $builder
50 3
            ->add('current_password', 'password', array(
51 3
                'label' => '現在のパスワード',
52
                'constraints' => array(
53 3
                    new Assert\NotBlank(),
54 3
                    new UserPassword(),
55
                ),
56
            ))
57 3
            ->add('change_password', 'repeated', array(
58
                'first_options'  => array(
59
                    'label' => '新しいパスワード',
60 3
                ),
61
                'second_options' => array(
62
                    'label' => '新しいパスワード(確認)',
63
                ),
64
                'constraints' => array(
65 3
                    new Assert\NotBlank(),
66 3
                    new Assert\Length(array(
67 3
                        'min' => $app['config']['password_min_len'],
68 3
                        'max' => $app['config']['password_max_len'],
69
                    )),
70 3
                    new Assert\Regex(array(
71 3
                        'pattern' => '/^[[:graph:][:space:]]+$/i',
72
                        'message' => 'form.type.graph.invalid',
0 ignored issues
show
introduced by
Please trim any trailing whitespace
Loading history...
73
                    )),
74
                ),
75
            ))
76 3
            ->addEventSubscriber(new \Eccube\Event\FormEventSubscriber());
0 ignored issues
show
Deprecated Code introduced by
The class Eccube\Event\FormEventSubscriber has been deprecated with message: since 3.0.0, to be removed in 3.1

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
77
        ;
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function setDefaultOptions(OptionsResolverInterface $resolver)
84
    {
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90 663
    public function getName()
91
    {
92 663
        return 'admin_change_password';
93
    }
94
}
95