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); |
|
|
|
|
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')); |
|
|
|
|
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
|
|
|
|
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: