ProductType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 138
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 138
ccs 40
cts 40
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configureOptions() 0 3 1
B buildForm() 0 102 1
A getName() 0 4 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\Admin;
26
27
use Doctrine\Common\Collections\ArrayCollection;
28
use Eccube\Application;
29
use Symfony\Component\Form\AbstractType;
30
use Symfony\Component\Form\FormBuilderInterface;
31
use Symfony\Component\OptionsResolver\OptionsResolver;
32
use Symfony\Component\Validator\Constraints as Assert;
33
34
/**
35
 * Class ProductType.
36
 */
37
class ProductType extends AbstractType
38
{
39
    /**
40
     * @var Application
41
     */
42
    public $app;
43
44
    /**
45
     * ProductType constructor.
46
     *
47
     * @param Application $app
48
     */
49 663
    public function __construct(Application $app)
50
    {
51 663
        $this->app = $app;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 19
    public function buildForm(FormBuilderInterface $builder, array $options)
58
    {
59
        /**
60
         * @var ArrayCollection $arrCategory array of category
61
         */
62 19
        $arrCategory = $this->app['eccube.repository.category']->getList(null, true);
63
64
        $builder
65
            // 商品規格情報
66 19
            ->add('class', 'admin_product_class', array(
67 19
                'mapped' => false,
68
            ))
69
            // 基本情報
70 19
            ->add('name', 'text', array(
71 19
                'label' => '商品名',
72
                'constraints' => array(
73 19
                    new Assert\NotBlank(),
74
                ),
75
            ))
76 19
            ->add('product_image', 'file', array(
77 19
                'label' => '商品画像',
78
                'multiple' => true,
79
                'required' => false,
80
                'mapped' => false,
81
            ))
82 19
            ->add('description_detail', 'textarea', array(
83 19
                'label' => '商品説明',
84
            ))
85 19
            ->add('description_list', 'textarea', array(
86 19
                'label' => '商品説明(一覧)',
87
                'required' => false,
88
            ))
89 19
            ->add('Category', 'entity', array(
90 19
                'class' => 'Eccube\Entity\Category',
91 19
                'property' => 'NameWithLevel',
92 19
                'label' => '商品カテゴリ',
93
                'multiple' => true,
94
                'mapped' => false,
95
                // Choices list (overdrive mapped)
96 19
                'choices' => $arrCategory,
97
            ))
98
99
            // 詳細な説明
100 19
            ->add('Tag', 'tag', array(
101 19
                'required' => false,
102
                'multiple' => true,
103
                'expanded' => true,
104
                'mapped' => false,
105
            ))
106 19
            ->add('search_word', 'textarea', array(
107 19
                'label' => "検索ワード",
108
                'required' => false,
109
            ))
110
            // サブ情報
111 19
            ->add('free_area', 'textarea', array(
112 19
                'label' => 'サブ情報',
113
                'required' => false,
114
            ))
115
116
            // 右ブロック
117 19
            ->add('Status', 'disp', array(
118
                'constraints' => array(
119 19
                    new Assert\NotBlank(),
120
                ),
121
            ))
122 19
            ->add('note', 'textarea', array(
123 19
                'label' => 'ショップ用メモ帳',
124
                'required' => false,
125
            ))
126
127
            // タグ
128 19
            ->add('tags', 'collection', array(
129 19
                'type' => 'hidden',
130
                'prototype' => true,
131
                'mapped' => false,
132
                'allow_add' => true,
133
                'allow_delete' => true,
134
            ))
135
            // 画像
136 19
            ->add('images', 'collection', array(
137 19
                'type' => 'hidden',
138
                'prototype' => true,
139
                'mapped' => false,
140
                'allow_add' => true,
141
                'allow_delete' => true,
142
            ))
143 19
            ->add('add_images', 'collection', array(
144 19
                'type' => 'hidden',
145
                'prototype' => true,
146
                'mapped' => false,
147
                'allow_add' => true,
148
                'allow_delete' => true,
149
            ))
150 19
            ->add('delete_images', 'collection', array(
151 19
                'type' => 'hidden',
152
                'prototype' => true,
153
                'mapped' => false,
154
                'allow_add' => true,
155
                'allow_delete' => true,
156
            ))
157
        ;
158
    }
159
160
    /**
161
     * {@inheritdoc}
162
     */
163
    public function configureOptions(OptionsResolver $resolver)
164
    {
165
    }
166
167
    /**
168
     * {@inheritdoc}
169
     */
170 663
    public function getName()
171
    {
172 663
        return 'admin_product';
173
    }
174
}
175