Exemplo n.º 1
0
 public function registerUsersToMultipleCursus(array $multipleCursus, array $users, $withWorkspace = true)
 {
     $registrationDate = new \DateTime();
     $this->om->startFlushSuite();
     foreach ($users as $user) {
         foreach ($multipleCursus as $cursus) {
             $cursusUser = $this->cursusUserRepo->findOneCursusUserByCursusAndUser($cursus, $user);
             if (is_null($cursusUser)) {
                 $cursusUser = new CursusUser();
                 $cursusUser->setCursus($cursus);
                 $cursusUser->setUser($user);
                 $cursusUser->setRegistrationDate($registrationDate);
                 $this->persistCursusUser($cursusUser);
                 $event = new LogCursusUserRegistrationEvent($cursus, $user);
                 $this->eventDispatcher->dispatch('log', $event);
                 if ($withWorkspace) {
                     $this->registerToCursusWorkspace($user, $cursus);
                 }
             }
         }
     }
     $this->om->endFlushSuite();
 }
Exemplo n.º 2
0
 public function cursusUser(User $user, Cursus $cursus, $type = 0)
 {
     $now = new \DateTime();
     $cursusUser = new CursusUser();
     $cursusUser->setUser($user);
     $cursusUser->setCursus($cursus);
     $cursusUser->setUserType($type);
     $cursusUser->setRegistrationDate($now);
     $this->om->persist($cursusUser);
     return $cursusUser;
 }