/** * Create an activity translation of the specified language * * @param ActivityModel $activity * @param type $language * @return \Activity\Model\ActivityTranslation */ protected function createActivityTranslation(ActivityModel $activity, $language) { $activityTranslation = new ActivityTranslationModel(); //Populate the common-language parts $activityTranslation->setId($activity->getId()); $activityTranslation->setBeginTime($activity->getBeginTime()); $activityTranslation->setEndTime($activity->getEndTime()); $activityTranslation->setCanSignUp($activity->getCanSignUp()); $activityTranslation->setOnlyGEWIS($activity->getOnlyGEWIS()); $activityTranslation->setApprover($activity->getApprover()); $activityTranslation->setCreator($activity->getCreator()); $activityTranslation->setStatus($activity->getStatus()); $activityTranslation->setSignUps($activity->getSignUps()); $activityTranslation->setSubscriptionDeadline($activity->getSubscriptionDeadline()); //TODO: add organ when relevant. if ($language === 'en') { $activityTranslation->setName($activity->getNameEn()); $activityTranslation->setLocation($activity->getLocationEn()); $activityTranslation->setCosts($activity->getCostsEn()); $activityTranslation->setDescription($activity->getDescriptionEn()); } if ($language === 'nl') { $activityTranslation->setName($activity->getName()); $activityTranslation->setLocation($activity->getLocation()); $activityTranslation->setCosts($activity->getCosts()); $activityTranslation->setDescription($activity->getDescription()); } $fieldTranslations = []; foreach ($activity->getFields() as $field) { $fieldTranslations[] = $this->createActivityFieldTranslation($field, $language); } $activityTranslation->setFields($fieldTranslations); return $activityTranslation; }
/** * Copies all relevant activity attributes from $new to $old * * @param ActivityModel $old * @param ActivityModel $new */ protected function copyActivity(ActivityModel $old, ActivityModel $new) { $old->setName($new->getName()); $old->setNameEn($new->getNameEn()); $old->setBeginTime($new->getBeginTime()); $old->setEndTime($new->getEndTime()); $old->setSubscriptionDeadline($new->getSubscriptionDeadline()); $old->setLocation($new->getLocation()); $old->setLocationEn($new->getLocationEn()); $old->setCosts($new->getCosts()); $old->setCostsEn($new->getCostsEn()); $old->setDescription($new->getDescription()); $old->setDescriptionEn($new->getDescriptionEn()); $old->setCreator($new->getCreator()); $old->setCanSignUp($new->getCanSignUp()); $old->setOnlyGEWIS($new->getOnlyGEWIS()); }