/** * 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; }