CommentType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 19 1
A getBlockPrefix() 0 4 1
A configureOptions() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
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 Sonata\NewsBundle\Form\Type;
15
16
use Symfony\Component\Form\AbstractType;
17
use Symfony\Component\Form\Extension\Core\Type\EmailType;
18
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
19
use Symfony\Component\Form\Extension\Core\Type\TextType;
20
use Symfony\Component\Form\Extension\Core\Type\UrlType;
21
use Symfony\Component\Form\FormBuilderInterface;
22
use Symfony\Component\OptionsResolver\OptionsResolver;
23
24
class CommentType extends AbstractType
25
{
26
    public function buildForm(FormBuilderInterface $builder, array $options): void
27
    {
28
        $builder
29
            ->add('name', TextType::class, [
30
                'label' => 'form.comment.name',
31
            ])
32
            ->add('email', EmailType::class, [
33
                'required' => false,
34
                'label' => 'form.comment.email',
35
            ])
36
            ->add('url', UrlType::class, [
37
                'required' => false,
38
                'label' => 'form.comment.url',
39
            ])
40
            ->add('message', TextareaType::class, [
41
                'label' => 'form.comment.message',
42
            ])
43
        ;
44
    }
45
46
    public function getBlockPrefix()
47
    {
48
        return 'sonata_post_comment';
49
    }
50
51
    public function configureOptions(OptionsResolver $resolver): void
52
    {
53
        $resolver->setDefaults([
54
            'translation_domain' => 'SonataNewsBundle',
55
        ]);
56
    }
57
}
58