コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $choices = [];
     if ($this->context->isGranted(User::ROLE_SUPER_ADMIN)) {
         $choices = $this->repository->findAll();
     } else {
         $groups = $this->groupResolver->getAccessibleGroupsId();
         $choices = $this->repository->findByGroups($groups);
     }
     $resolver->setDefaults(array('label' => 'game.selectMachine', 'class' => 'DPMachineBundle:Machine', 'choices' => $choices));
 }