Skip to content

Commit

Permalink
Fix deprecated setAllowedTypes method
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh committed Apr 20, 2015
1 parent 7da9c0d commit ddc357c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 8 additions & 3 deletions Block/AdminListBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Sonata\AdminBundle\Admin\Pool;
use Sonata\BlockBundle\Block\BaseBlockService;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
Expand Down Expand Up @@ -81,8 +82,12 @@ public function setDefaultSettings(OptionsResolverInterface $resolver)
'groups' => false
));

$resolver->setAllowedTypes(array(
'groups' => array('bool', 'array')
));
if (version_compare(Kernel::VERSION, '2.6', '<')) {
$resolver->setAllowedTypes(array(
'groups' => array('bool', 'array')
));
} else {
$resolver->setAllowedTypes('groups', array('bool', 'array'));
}
}
}
14 changes: 10 additions & 4 deletions Form/Type/AclMatrixType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Security\Core\User\UserInterface;
Expand Down Expand Up @@ -62,10 +63,15 @@ public function configureOptions(OptionsResolver $resolver)
'acl_value',
));

$resolver->setAllowedTypes(array(
'permissions' => 'array',
'acl_value' => array('string', '\Symfony\Component\Security\Core\User\UserInterface'),
));
if (version_compare(Kernel::VERSION, '2.6', '<')) {
$resolver->setAllowedTypes(array(
'permissions' => 'array',
'acl_value' => array('string', '\Symfony\Component\Security\Core\User\UserInterface'),
));
} else {
$resolver->setAllowedTypes('permissions', 'array');
$resolver->setAllowedTypes('acl_value', array('string', '\Symfony\Component\Security\Core\User\UserInterface'));
}
}

/**
Expand Down

0 comments on commit ddc357c

Please sign in to comment.