1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Lakion\CmsPlugin\Form\Type; |
4
|
|
|
|
5
|
|
|
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; |
6
|
|
|
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonAutocompleteChoiceType; |
7
|
|
|
use Symfony\Component\Form\Extension\Core\Type\FileType; |
8
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
9
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
10
|
|
|
|
11
|
|
View Code Duplication |
final class TaxonBlockType extends AbstractResourceType |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* {@inheritdoc} |
15
|
|
|
*/ |
16
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
17
|
|
|
{ |
18
|
|
|
$builder |
19
|
|
|
->add('name', TextType::class, [ |
20
|
|
|
'label' => 'lakion_cms.form.taxon_block.name', |
21
|
|
|
]) |
22
|
|
|
->add('title', TextType::class, [ |
23
|
|
|
'label' => 'lakion_cms.form.taxon_block.title', |
24
|
|
|
]) |
25
|
|
|
->add('body', TextType::class, [ |
26
|
|
|
'label' => 'lakion_cms.form.taxon_block.body', |
27
|
|
|
]) |
28
|
|
|
->add('linkUrl', TextType::class, [ |
29
|
|
|
'label' => 'lakion_cms.form.taxon_block.link', |
30
|
|
|
]) |
31
|
|
|
->add('image', FileType::class, [ |
32
|
|
|
'label' => 'lakion_cms.form.taxon_block.image', |
33
|
|
|
]) |
34
|
|
|
->add('taxon', TaxonAutocompleteChoiceType::class, [ |
35
|
|
|
'label' => 'lakion_cms.form.taxon_block.taxon', |
36
|
|
|
'multiple' => false, |
37
|
|
|
'required' => true, |
38
|
|
|
]) |
39
|
|
|
; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
public function getBlockPrefix() |
46
|
|
|
{ |
47
|
|
|
return 'lakion_cms_taxon_block'; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
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.