Completed
Push — master ( b05eaa...0a1951 )
by Paweł
16:26 queued 07:46
created

DateFilterType::getBlockPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Bundle\GridBundle\Form\Type\Filter;
13
14
use Sylius\Component\Grid\Filter\StringFilter;
15
use Symfony\Component\Form\AbstractType;
16
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
17
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
18
use Symfony\Component\Form\Extension\Core\Type\TextType;
19
use Symfony\Component\Form\FormBuilderInterface;
20
use Symfony\Component\OptionsResolver\OptionsResolver;
21
22
/**
23
 * @author Grzegorz Sadowski <[email protected]>
24
 */
25
final class DateFilterType extends AbstractType
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function buildForm(FormBuilderInterface $builder, array $options)
31
    {
32
        $builder
33
            ->add('from', DateTimeType::class, [
34
                'label' => 'sylius.ui.from',
35
                'date_widget' => 'single_text',
36
                'time_widget' => 'single_text',
37
                'required' => false,
38
            ])
39
            ->add('to', DateTimeType::class, [
40
                'label' => 'sylius.ui.to',
41
                'date_widget' => 'single_text',
42
                'time_widget' => 'single_text',
43
                'required' => false,
44
            ])
45
        ;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function configureOptions(OptionsResolver $resolver)
52
    {
53
        $resolver
54
            ->setDefaults([
55
                'data_class' => null,
56
            ])
57
            ->setDefined('field')
58
            ->setAllowedTypes('field', 'string')
59
        ;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function getBlockPrefix()
66
    {
67
        return 'sylius_grid_filter_date';
68
    }
69
}
70