Exemple #1
0
 /**
  * Inserts a company into the datebase, and initializes the given 
  * translations as empty translations for them
  *
  * @param mixed $languages
  */
 public function insert($languages)
 {
     $company = new CompanyModel($this->em);
     $companiesBySameSlugName = $this->findEditableCompaniesBySlugName($company->getSlugName(), false);
     // Only for testing, logo will be implemented in a later issue, and it will be validated before it comes here, so this will never be called in production code. TODO: remove this when implemented logo and logo validation
     foreach ($languages as $language) {
         $translation = new CompanyI18n($language, $company);
         if (is_null($translation->getLogo())) {
             $translation->setLogo('');
         }
         $this->em->persist($translation);
         $company->addTranslation($translation);
     }
     $company->setHidden(false);
     $this->em->persist($company);
     return $company;
 }
Exemple #2
0
 /**
  * Returns the translation identified by $language
  *
  * Note, does not set $logo, the user should set this property himself
  *
  * @param mixed $data
  * @param mixed $language
  */
 public function getTranslationFromArray($data, $language)
 {
     if ($language !== '') {
         $translation = $this->getTranslationFromLocale($language);
         if (is_null($translation)) {
             $translation = new CompanyI18n($language, $this);
         }
         $language = $language . '_';
         // Translated properties
         $translation->setWebsite($this->updateIfSet($data[$language . 'website'], ''));
         $translation->setSlogan($this->updateIfSet($data[$language . 'slogan'], ''));
         $translation->setDescription($this->updateIfSet($data[$language . 'description'], ''));
         // Do not set logo, because most likely, $data[logo] is bogus.
         // Instead, the user should set this property himself later.
         return $translation;
     }
 }