/**
  * @param RZ\Roadiz\Core\Entities\User  $user
  * @param RZ\Roadiz\Core\Entities\Group $group
  *
  * @return \Symfony\Component\Form\Form
  */
 private function buildRemoveGroupForm(User $user, Group $group)
 {
     $builder = $this->createFormBuilder()->add('userId', 'hidden', ['data' => $user->getId(), 'constraints' => [new NotBlank()]])->add('groupId', 'hidden', ['data' => $group->getId(), 'constraints' => [new NotBlank()]]);
     return $builder->getForm();
 }
Example #2
0
 /**
  * @param array                        $data
  * @param RZ\Roadiz\Core\Entities\Group $group
  * @param RZ\Roadiz\Core\EntitiesUser   $user
  *
  * @return RZ\Roadiz\Core\Entities\User
  */
 private function removeUser($data, Group $group, User $user)
 {
     if ($data['groupId'] == $group->getId() && $data['userId'] == $user->getId()) {
         if ($user !== null) {
             $user->removeGroup($group);
             $this->getService('em')->flush();
         }
         return $user;
     }
 }