Completed
Push — master ( 424407...314f1e )
by Jan
05:39 queued 32s
created

CategoryAdminForm::additionalFormElements()   B

Complexity

Conditions 9
Paths 1

Size

Total Lines 35
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 25
nc 1
nop 3
dl 0
loc 35
rs 8.0555
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * part-db version 0.1
5
 * Copyright (C) 2005 Christoph Lechner
6
 * http://www.cl-projects.de/
7
 *
8
 * part-db version 0.2+
9
 * Copyright (C) 2009 K. Jacobs and others (see authors.php)
10
 * http://code.google.com/p/part-db/
11
 *
12
 * Part-DB Version 0.4+
13
 * Copyright (C) 2016 - 2019 Jan Böhmer
14
 * https://github.com/jbtronics
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
29
 *
30
 */
31
32
namespace App\Form;
33
34
35
use App\Entity\NamedDBElement;
36
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
37
use Symfony\Component\Form\Extension\Core\Type\TextType;
38
use Symfony\Component\Form\FormBuilderInterface;
39
40
class CategoryAdminForm extends BaseEntityAdminForm
41
{
42
    protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
43
    {
44
        $is_new = $entity->getID() === null;
45
46
        $builder->add('disable_footprints', CheckboxType::class, ['required' => false,
47
            'label' => 'disable_footprints.label', 'help' => 'disable_footprints.help', 'label_attr'=> ['class' => 'checkbox-custom'],
48
                'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
49
50
        $builder->add('disable_manufacturers', CheckboxType::class, ['required' => false,
51
            'label' => 'disable_manufacturers.label', 'help' => 'disable_manufacturers.help', 'label_attr'=> ['class' => 'checkbox-custom'],
52
            'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
53
54
        $builder->add('disable_autodatasheets', CheckboxType::class, ['required' => false,
55
            'label' => 'disable_autodatasheets.label', 'help' => 'disable_autodatasheets.help', 'label_attr'=> ['class' => 'checkbox-custom'],
56
            'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
57
58
        $builder->add('disable_properties', CheckboxType::class, ['required' => false,
59
            'label' => 'disable_properties.label', 'help' => 'disable_properties.help', 'label_attr'=> ['class' => 'checkbox-custom'],
60
            'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
61
62
        $builder->add('partname_hint', TextType::class, ['required' => false, 'empty_data' => '',
63
            'label' => 'disable_manufacturers.label', 'attr' => ['placeholder' => 'disable_manufacturers.placeholder'],
64
            'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
65
66
        $builder->add('partname_regex', TextType::class, ['required' => false, 'empty_data' => '',
67
            'label' => 'partname_regex.label', 'attr' => ['placeholder' => 'partname_regex.placeholder'],
68
            'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
69
70
        $builder->add('default_description', TextType::class, ['required' => false, 'empty_data' => '',
71
            'label' => 'default_description.label', 'attr' => ['placeholder' => 'default_description.placeholder'],
72
            'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
73
74
        $builder->add('default_comment', TextType::class, ['required' => false, 'empty_data' => '',
75
            'label' => 'default_description.label', 'attr' => ['placeholder' => 'default_comment.placeholder'],
76
            'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
0 ignored issues
show
introduced by
The condition $is_new is always false.
Loading history...
77
    }
78
}