예제 #1
0
 public function load(ObjectManager $manager)
 {
     $role_manager = ProjectRole::PROJECT_ROLE_LEADER;
     $role = new ProjectRole();
     $role->setName($role_manager);
     $manager->persist($role);
     $project = new Project();
     $project->setName('Project1');
     $manager->persist($project);
     $projectUser = new ProjectUser();
     $projectUser->setProject($project);
     $projectUser->setUser($this->getReference('user1'));
     $projectUser->addRole($role);
     $manager->persist($projectUser);
     $projectUser = new ProjectUser();
     $projectUser->setProject($project);
     $projectUser->setUser($this->getReference('user2'));
     $manager->persist($projectUser);
     $project = new Project();
     $project->setName('Project2');
     $this->addReference('Project2', $project);
     $manager->persist($project);
     $projectUser = new ProjectUser();
     $projectUser->setProject($project);
     $projectUser->setUser($this->getReference('user3'));
     $manager->persist($projectUser);
     $projectUser = new ProjectUser();
     $projectUser->setProject($project);
     $projectUser->setUser($this->getReference('user4'));
     $manager->persist($projectUser);
     $manager->flush();
     $projectService = $this->container->get('app.project.service');
     $projectService->setUserToProjectLeader($this->getReference('user3'), $this->getReference('Project2'));
     $projectService->addUserToProject($this->getReference('user1'), $manager->getRepository('CustomFosUserBundle:Project')->findOneByName('Project2'));
 }
예제 #2
0
 public function addUserToProject($user, $project)
 {
     if (!$user->hasProject($project->getName())) {
         $projectUser = new ProjectUser();
         $projectUser->setProject($project);
         $projectUser->setUser($user);
         $this->em->persist($projectUser);
         $this->em->flush();
     }
 }
예제 #3
0
 public function addUserToProject($user, $project)
 {
     if (!$user->hasProject($project->getName())) {
         $projectUser = new ProjectUser();
         $projectUser->setProject($project);
         $projectUser->setUser($user);
         $this->em->persist($projectUser);
         $this->em->flush();
         $this->logger->info('OK project added');
         return $projectUser;
     }
 }