NewsType::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 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
namespace Eccube\Form\Type\Admin;
25
26
use Symfony\Component\Form\AbstractType;
27
use Symfony\Component\Form\FormBuilderInterface;
28
use Symfony\Component\OptionsResolver\OptionsResolver;
29
use Symfony\Component\Validator\Constraints as Assert;
30
31
class NewsType extends AbstractType
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
32
{
33
    private $config;
34
35 663
    public function __construct($config)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
36
    {
37 663
        $this->config = $config;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 5
    public function buildForm(FormBuilderInterface $builder, array $options)
44
    {
45
        $builder
46 5
            ->add('date', 'date', array(
47 5
                'label' => '日付',
48
                'required' => true,
49 5
                'input' => 'datetime',
50 5
                'widget' => 'single_text',
51 5
                'format' => 'yyyy-MM-dd',
52
                'empty_value' => array('year' => '----', 'month' => '--', 'day' => '--'),
53
                'constraints' => array(
54 5
                    new Assert\NotBlank(),
55
                ),
56
            ))
57 5
            ->add('title', 'text', array(
58 5
                'label' => 'タイトル',
59
                'required' => true,
60
                'constraints' => array(
61 5
                    new Assert\NotBlank(),
62 5
                    new Assert\Length(array('max' => $this->config['mtext_len'])),
63
                ),
64
            ))
65 5
            ->add('url', 'text', array(
66 5
                'label' => 'URL',
67
                'required' => false,
68
                'constraints' => array(
69 5
                    new Assert\Url(),
70 5
                    new Assert\Length(array('max' => $this->config['mtext_len'])),
71
                ),
72
            ))
73 5
            ->add('link_method', 'checkbox', array(
74 5
                'required' => false,
75
                'label' => '別ウィンドウを開く',
76
                'value' => '1',
77
            ))
78 5
            ->add('comment', 'textarea', array(
79 5
                'label' => '本文',
80
                'required' => false,
81
                'constraints' => array(
82 5
                    new Assert\Length(array('max' => $this->config['ltext_len'])),
83
                ),
84
            ))
85 5
            ->add('select', 'hidden', array(
86 5
                'data' => '0',
87
            ));
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 5
    public function configureOptions(OptionsResolver $resolver)
94
    {
95 5
        $resolver->setDefaults(array(
96 5
            'data_class' => 'Eccube\Entity\News',
97
        ));
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103 663
    public function getName()
104
    {
105 663
        return 'admin_news';
106
    }
107
}
108