Example #1
0
 /**
  * Create an activity from parameters.
  *
  * @pre $params is valid data of Activity\Form\Activity
  *
  * @param array $params Parameters describing activity
  * @param User $user The user that creates this activity
  * @param Organ $organ The organ this activity is associated with
  * @param boolean $dutch Whether dutch information is provided
  * @param boolean $english Whether english information is provided
  *
  * @return ActivityModel Activity that was created.
  */
 protected function generateActivity(array $params, $user, $organ, $dutch, $english, $initialStatus)
 {
     $activity = new ActivityModel();
     $activity->setBeginTime(new \DateTime($params['beginTime']));
     $activity->setEndTime(new \DateTime($params['endTime']));
     //Default to the endtime if no deadline was set (so there is no deadline effectively)
     $activity->setSubscriptionDeadline(empty($params['subscriptionDeadline']) ? $activity->getEndTime() : new \DateTime($params['subscriptionDeadline']));
     $this->setLanguageSpecificParameters($activity, $params, $dutch, $english);
     $activity->setCanSignUp($params['canSignUp']);
     // Not user provided input
     $activity->setCreator($user);
     $activity->setOrgan($organ);
     $activity->setStatus($initialStatus);
     $activity->setOnlyGEWIS(true);
     // Not yet implemented
     $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     if (isset($params['fields'])) {
         foreach ($params['fields'] as $fieldparams) {
             $field = $this->createActivityField($fieldparams, $activity, $dutch, $english);
             $em->persist($field);
         }
         $em->flush();
     }
     $em->persist($activity);
     $em->flush();
     $this->getEmailService()->sendActivityCreationEmail($activity);
     return $activity;
 }