Completed
Push — 4.0 ( 268f2c...88f012 )
by Hideki
05:48 queued 10s
created

src/Eccube/Form/Type/Admin/ClassNameType.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Form\Type\Admin;
15
16
use Eccube\Common\EccubeConfig;
17
use Symfony\Component\Form\AbstractType;
18
use Symfony\Component\Form\Extension\Core\Type\TextType;
19
use Symfony\Component\Form\FormBuilderInterface;
20
use Symfony\Component\OptionsResolver\OptionsResolver;
21
use Symfony\Component\Validator\Constraints as Assert;
22
23
class ClassNameType extends AbstractType
24
{
25
    /**
26
     * @var EccubeConfig
27
     */
28
    protected $eccubeConfig;
29
30
    /**
31
     * {@inheritdoc}
32
     *
33
     * ClassNameType constructor.
34
     *
35
     * @param EccubeConfig $eccubeConfig
36
     */
37 10
    public function __construct(EccubeConfig $eccubeConfig)
38
    {
39 10
        $this->eccubeConfig = $eccubeConfig;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 10 View Code Duplication
    public function buildForm(FormBuilderInterface $builder, array $options)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        $builder
48 10
            ->add('name', TextType::class, [
49 10
                'constraints' => [
50
                    new Assert\NotBlank(),
51 10
                    new Assert\Length([
52 10
                        'max' => $this->eccubeConfig['eccube_stext_len'],
53 10
                    ]),
54
                ],
55
            ])
56
            ->add('backend_name', TextType::class, [
57 10
                'required' => false,
58 10
                'constraints' => [
59
                    new Assert\Length([
60
                        'max' => $this->eccubeConfig['eccube_stext_len'],
61 10
                    ]),
62 10
                ],
63
            ])
64
        ;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function configureOptions(OptionsResolver $resolver)
71
    {
72 10
        $resolver->setDefaults([
73
            'data_class' => 'Eccube\Entity\ClassName',
74 10
        ]);
75 10
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function getBlockPrefix()
81
    {
82 10
        return 'admin_class_name';
83
    }
84
}
85