예제 #1
0
 /**
  * Remove given Access Role to User
  *
  * @param AccessRole $accessRole
  *
  * @return User
  */
 public function removeAccessRole(AccessRole $accessRole)
 {
     $this->accessRole->removeElement($accessRole);
     return $this;
 }
예제 #2
0
 /**
  * Remove given Access Roles from company
  *
  * @param AccessRole $companyRoles
  * @return Company
  */
 public function removeCompanyRoles(AccessRole $companyRoles)
 {
     $this->companyRoles->removeElement($companyRoles);
     return $this;
 }
예제 #3
0
 /**
  * Remove given Access Role from Project
  *
  * @param AccessRole $projectRoles
  * @return Project
  */
 public function removeProjectRoles(AccessRole $projectRoles)
 {
     $this->projectRoles->removeElement($projectRoles);
     return $this;
 }
 /**
  * Create new access role for given project
  *
  * @Route("/{id}/role-project", name="admin_create_project_access_role")
  * @Method("GET|POST")
  * @Template("GPUserBundle:Admin/AccessRole:createProjectAccessRole.html.twig")
  */
 public function createProjectAccessRoleAction(Request $request, $id)
 {
     // Searching requested project
     $em = $this->getDoctrine()->getManager();
     $project = $em->getRepository('GPCoreBundle:Project')->find($id);
     // Checking if project exists
     if (!$project) {
         $this->addFlash('error', 'Projet introuvable');
         return $this->redirectToRoute('admin_show_all_project');
     }
     $accessRole = new AccessRole();
     $accessRole->setType(AccessRole::TYPE_PROJECT);
     $accessRole->setProject($project);
     $form = $this->createForm(new AddAccessRoleType(), $accessRole);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($accessRole);
         $em->flush();
         $logger = $this->get('monolog.logger.user_access');
         $logger->alert('[PROJECT_ROLE_ADD] ' . $this->getUser()->getEmail() . ' have added new role ' . $accessRole->getName() . ' to project ' . $project->getName());
         $this->addFlash('success', 'Le rôle: ' . $accessRole->getName() . ' a été ajouté avec succès au projet ' . $project->getName());
         return $this->redirectToRoute('admin_show_project', array('id' => $id));
     }
     return array('form' => $form->createView(), 'project' => $project);
 }