예제 #1
0
 /**
  * Create an option translation of the specified language
  * @param ActivityOptionModel $option
  * @param string $language 'nl' or 'en'
  * @return \Activity\Model\ActivityOptionTranslation
  */
 protected function createActivityOptionTranslation(ActivityOptionModel $option, $language)
 {
     $optionTranslation = new OptionTranslationModel();
     //Populate the common-language parts
     $optionTranslation->setField($option->getField());
     $optionTranslation->setId($option->getId());
     if ($language === 'en') {
         $optionTranslation->setValue($option->getValueEn());
     }
     if ($language === 'nl') {
         $optionTranslation->setValue($option->getValue());
     }
     return $optionTranslation;
 }
예제 #2
0
 /**
  * Creates options for both languages specified and adds it to $field.
  * If no languages are specified, this method does nothing.
  * @pre The options corresponding to the languages specified are filled in
  * $params. If both languages are specified, they must have the same amount of options.
  *
  * @param ActivityFieldModel $field The field to add the options to.
  * @param array $params The array containing the options strings.
  * @param bool $createEnglishOptions
  * @param bool $createDutchOptions
  */
 protected function createActivityOptions($field, $params, $createEnglishOptions, $createDutchOptions)
 {
     $numOptions = 0;
     $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     if ($createDutchOptions) {
         $options = explode(',', $params['options']);
         $numOptions = count($options);
     }
     if ($createEnglishOptions) {
         $optionsEn = explode(',', $params['optionsEn']);
         $numOptions = count($optionsEn);
     }
     for ($i = 0; $i < $numOptions; $i++) {
         $option = new ActivityOptionModel();
         if ($createDutchOptions) {
             $option->setValue($options[$i]);
         }
         if ($createEnglishOptions) {
             $option->setValueEn($optionsEn[$i]);
         }
         $option->setField($field);
         $em->persist($option);
     }
     $em->flush();
 }