EntryType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 81
ccs 38
cts 38
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setDefaultOptions() 0 6 1
A getName() 0 5 1
A buildForm() 0 49 1
1
<?php
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
25
namespace Eccube\Form\Type\Front;
26
27
use Symfony\Component\Form\AbstractType;
28
use Symfony\Component\Form\Extension\Core\Type;
29
use Symfony\Component\Form\FormBuilderInterface;
30
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
31
use Symfony\Component\Validator\Constraints as Assert;
32
33
class EntryType extends AbstractType
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
34
{
35
    protected $config;
36
37 663
    public function __construct($config)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
38
    {
39 663
        $this->config = $config;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 32
    public function buildForm(FormBuilderInterface $builder, array $options)
46
    {
47
        $builder
48 32
            ->add('name', 'name', array(
49 32
                'required' => true,
50
            ))
51 32
            ->add('kana', 'kana', array(
52 32
                'required' => true,
53
            ))
54 32
            ->add('company_name', 'text', array(
55 32
                'required' => false,
56
                'constraints' => array(
57 32
                    new Assert\Length(array(
58 32
                        'max' => $this->config['stext_len'],
59
                    )),
60
                ),
61
            ))
62 32
            ->add('zip', 'zip')
63 32
            ->add('address', 'address')
64 32
            ->add('tel', 'tel', array(
65 32
                'required' => true,
66
            ))
67 32
            ->add('fax', 'tel', array(
68 32
                'required' => false,
69
            ))
70 32
            ->add('email', 'repeated_email')
71 32
            ->add('password', 'repeated_password')
72 32
            ->add('birth', 'birthday', array(
73 32
                'required' => false,
74 32
                'input' => 'datetime',
75 32
                'years' => range(date('Y'), date('Y') - $this->config['birth_max']),
76 32
                'widget' => 'choice',
77 32
                'format' => 'yyyy/MM/dd',
78
                'empty_value' => array('year' => '----', 'month' => '--', 'day' => '--'),
79
                'constraints' => array(
80 32
                    new Assert\LessThanOrEqual(array(
81 32
                        'value' => date('Y-m-d'),
82 32
                        'message' => 'form.type.select.selectisfuturedate',
83
                    )),
84
                ),
85
            ))
86 32
            ->add('sex', 'sex', array(
87 32
                'required' => false,
88
            ))
89 32
            ->add('job', 'job', array(
90 32
                'required' => false,
91
            ))
92 32
            ->add('save', 'submit', array('label' => 'この内容で登録する'));
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98 32
    public function setDefaultOptions(OptionsResolverInterface $resolver)
99
    {
100 32
        $resolver->setDefaults(array(
101 32
            'data_class' => 'Eccube\Entity\Customer',
102
        ));
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108 663
    public function getName()
109
    {
110
        // todo entry,mypageで共有されているので名前を変更する
111 663
        return 'entry';
112
    }
113
}
114