diff --git a/Form/Type/ScopePickerType.php b/Form/Type/ScopePickerType.php index 73cd96d12..1b9f1a68c 100644 --- a/Form/Type/ScopePickerType.php +++ b/Form/Type/ScopePickerType.php @@ -15,32 +15,25 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ + namespace Chill\MainBundle\Form\Type; +use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\DataMapper\ScopePickerDataMapper; -use Doctrine\ORM\QueryBuilder; -use Symfony\Component\Form\AbstractType; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\EntityRepository; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\Options; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; -use Chill\MainBundle\Entity\Scope; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\MainBundle\Entity\Center; use Symfony\Component\Security\Core\Role\Role; /** @@ -93,7 +86,7 @@ class ScopePickerType extends AbstractType $query = $this->buildAccessibleScopeQuery($options['center'], $options['role']); $items = $query->getQuery()->execute(); - if (count($items) !== 1) { + if (1 !== count($items)) { $builder->add( 'scope', EntityType::class, [ 'class' => Scope::class, @@ -131,14 +124,13 @@ class ScopePickerType extends AbstractType $resolver // create `center` option ->setRequired('center') - ->setAllowedTypes('center', [Center::class ]) + ->setAllowedTypes('center', [Center::class]) // create ``role` option ->setRequired('role') - ->setAllowedTypes('role', ['string', Role::class ]); + ->setAllowedTypes('role', ['string', Role::class]); } /** - * * @return \Doctrine\ORM\QueryBuilder */ protected function buildAccessibleScopeQuery(Center $center, Role $role)