Completed
Push — master ( c83c24...c0f573 )
by Paweł
24:31 queued 14:40
created

ProductAutocompleteChoiceType::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
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\ProductBundle\Form\Type;
13
14
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
15
use Symfony\Component\Form\AbstractType;
16
use Symfony\Component\Form\FormInterface;
17
use Symfony\Component\Form\FormView;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
20
/**
21
 * @author Łukasz Chruściel <[email protected]>
22
 */
23
final class ProductAutocompleteChoiceType extends AbstractType
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function configureOptions(OptionsResolver $resolver)
29
    {
30
        $resolver->setDefaults([
31
            'resource' => 'sylius.product',
32
            'choice_name' => 'name',
33
            'choice_value' => 'code',
34
        ]);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function buildView(FormView $view, FormInterface $form, array $options)
41
    {
42
        $view->vars['remote_criteria_type'] = 'contains';
43
        $view->vars['remote_criteria_name'] = 'phrase';
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getBlockPrefix()
50
    {
51
        return 'sylius_product_autocomplete_choice';
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getParent()
58
    {
59
        return ResourceAutocompleteChoiceType::class;
60
    }
61
}
62