Issues (3627)

bundles/LeadBundle/Form/Type/LeadCategoryType.php (1 issue)

1
<?php
2
3
/*
4
 * @copyright   2014 Mautic Contributors. All rights reserved
5
 * @author      Mautic
6
 *
7
 * @link        http://mautic.org
8
 *
9
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10
 */
11
12
namespace Mautic\LeadBundle\Form\Type;
13
14
use Mautic\CategoryBundle\Model\CategoryModel;
15
use Symfony\Component\Form\AbstractType;
16
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
17
use Symfony\Component\OptionsResolver\Options;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
20
class LeadCategoryType extends AbstractType
21
{
22
    private $categoryModel;
23
24
    public function __construct(CategoryModel $categoryModel)
25
    {
26
        $this->categoryModel = $categoryModel;
27
    }
28
29
    public function configureOptions(OptionsResolver $resolver)
30
    {
31
        $resolver->setDefaults([
32
            'choices'           => function (Options $options) {
0 ignored issues
show
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
            'choices'           => function (/** @scrutinizer ignore-unused */ Options $options) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
                $categories = $this->categoryModel->getLookupResults('global');
34
                $choices    = [];
35
36
                foreach ($categories as $cat) {
37
                    $choices[$cat['title']] = $cat['id'];
38
                }
39
40
                return $choices;
41
            },
42
            'global_only' => true,
43
            'required'    => false,
44
        ]);
45
    }
46
47
    /**
48
     * @return string|\Symfony\Component\Form\FormTypeInterface|null
49
     */
50
    public function getParent()
51
    {
52
        return ChoiceType::class;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getBlockPrefix()
59
    {
60
        return 'leadcategory_choices';
61
    }
62
}
63