Completed
Push — 2.8-deprecations ( 190cf3 )
by David
17:23
created

TreeManagerType::configureOptions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
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
13
namespace Sonata\DoctrinePHPCRAdminBundle\Form\Type;
14
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
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
20
21
class TreeManagerType extends AbstractType
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function buildView(FormView $view, FormInterface $form, array $options)
27
    {
28
        $view->vars['root'] = $options['root'];
29
        //$view->vars['create_in_overlay'] = $options['create_in_overlay'];
30
        //$view->vars['edit_in_overlay'] = $options['edit_in_overlay'];
31
        //$view->vars['delete_in_overlay'] = $options['delete_in_overlay'];
32
        parent::buildView($view, $form, $options);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function setDefaultOptions(OptionsResolverInterface $resolver)
39
    {
40
        $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...
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function configureOptions(OptionsResolver $resolver)
47
    {
48
        $resolver->setRequired(array('root'));
49
50
        if (method_exists($resolver, 'setDefined')) {
51
            // The new OptionsResolver API
52
            $resolver->setDefined(array('create_in_overlay', 'edit_in_overlay', 'delete_in_overlay'));
53
        } else {
54
            // To keep compatibility with old Symfony <2.6 API
55
            $resolver->setOptional(array('create_in_overlay', 'edit_in_overlay', 'delete_in_overlay'));
0 ignored issues
show
Bug introduced by
The method setOptional() does not seem to exist on object<Symfony\Component...solver\OptionsResolver>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
        }
57
58
        $resolver->setDefaults(array(
59
            'create_in_overlay' => true,
60
            'edit_in_overlay'   => true,
61
            'delete_in_overlay' => true,
62
        ));
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     *
68
     * @todo Remove when Symfony <2.8 is no longer supported
69
     */
70
    public function getName()
71
    {
72
        return $this->getBlockPrefix();
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function getBlockPrefix()
79
    {
80
        return 'doctrine_phpcr_odm_tree_manager';
81
    }
82
}
83