Completed
Push — master ( 265a2d...f9e310 )
by jerome
02:58
created

TeamspeakServerType::buildForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 24
rs 8.9713
cc 1
eloc 17
nc 1
nop 2
1
<?php
2
3
/**
4
 * This file is part of Dedipanel project
5
 *
6
 * (c) 2010-2015 Dedipanel <http://www.dedicated-panel.net>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DP\VoipServer\TeamspeakServerBundle\Form;
13
14
use Symfony\Component\Form\AbstractType;
15
use Symfony\Component\Form\FormBuilderInterface;
16
use Symfony\Component\Form\FormEvent;
17
use Symfony\Component\Form\FormEvents;
18
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
19
20
class TeamspeakServerType extends AbstractType
21
{
22
    public function buildForm(FormBuilderInterface $builder, array $options)
23
    {
24
        /** @var \DP\VoipServer\TeamspeakServerBundle\Entity\TeamspeakServer $teamspeak */
25
        $teamspeak = $builder->getData();
26
27
        $builder
28
            ->add('machine', 'dedipanel_machine_entity')
29
            ->add('dir', 'text', ['label' => 'game.dir'])
30
            ->add('voice_port', 'number', ['label' => 'voip.voice_port'])
31
            ->add('query_port', 'number', ['label' => 'voip.query_port'])
32
            ->add('query_password', 'password', ['label' => 'voip.query_password'])
33
            ->add('filetransfer_port', 'number', ['label' => 'teamspeak.filetransfer_port'])
34
            ->add('licence_file', 'file', [
35
                'label'    => 'teamspeak.licence',
36
                'required' => false,
37
            ])
38
            ->add('core', 'dedipanel_core_assignment', ['machine' => $teamspeak->getMachine()])
39
            ->add('alreadyInstalled', 'dictionary', [
40
                'name'     => 'yes_no',
41
                'label'    => 'game.isAlreadyInstalled',
42
                'expanded' => true
43
            ])
44
        ;
45
    }
46
47 View Code Duplication
    public function setDefaultOptions(OptionsResolverInterface $resolver)
0 ignored issues
show
Duplication introduced by
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...
48
    {
49
        $resolver
50
            ->setDefaults([
51
                'remove_on_create'  => ['core'],
52
                'remove_on_update'  => ['alreadyInstalled'],
53
                'disable_on_update' => ['machine', 'dir'],
54
            ])
55
        ;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function getName()
62
    {
63
        return 'dedipanel_teamspeak';
64
    }
65
}
66