TreeManagerType   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setDefaultOptions() 0 4 1
A buildView() 0 8 1
A configureOptions() 0 13 1
A getName() 0 4 1
A getBlockPrefix() 0 4 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\DoctrinePHPCRAdminBundle\Form\Type;
15
16
use Symfony\Component\Form\AbstractType;
17
use Symfony\Component\Form\FormInterface;
18
use Symfony\Component\Form\FormView;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
21
22
class TreeManagerType extends AbstractType
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function buildView(FormView $view, FormInterface $form, array $options): void
28
    {
29
        $view->vars['root'] = $options['root'];
30
        //$view->vars['create_in_overlay'] = $options['create_in_overlay'];
31
        //$view->vars['edit_in_overlay'] = $options['edit_in_overlay'];
32
        //$view->vars['delete_in_overlay'] = $options['delete_in_overlay'];
33
        parent::buildView($view, $form, $options);
34
    }
35
36
    /**
37
     * NEXT_MAJOR: remove this method.
38
     */
39
    public function setDefaultOptions(OptionsResolverInterface $resolver): void
40
    {
41
        $this->configureOptions($resolver);
0 ignored issues
show
Documentation introduced by
$resolver is of type object<Symfony\Component...tionsResolverInterface>, but the function expects a object<Symfony\Component...solver\OptionsResolver>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function configureOptions(OptionsResolver $resolver): void
48
    {
49
        $resolver->setRequired(['root']);
50
51
        // The new OptionsResolver API
52
        $resolver->setDefined(['create_in_overlay', 'edit_in_overlay', 'delete_in_overlay']);
53
54
        $resolver->setDefaults([
55
            'create_in_overlay' => true,
56
            'edit_in_overlay' => true,
57
            'delete_in_overlay' => true,
58
        ]);
59
    }
60
61
    /**
62
     * NEXT_MAJOR: remove this method.
63
     */
64
    public function getName()
65
    {
66
        return $this->getBlockPrefix();
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function getBlockPrefix()
73
    {
74
        return 'doctrine_phpcr_odm_tree_manager';
75
    }
76
}
77