Exemple #1
0
 /**
  * Creates a new category translation for a given category and locale.
  *
  * @param CategoryInterface $category
  * @param $locale
  *
  * @return CategoryTranslationInterface
  */
 private function createTranslation(CategoryInterface $category, $locale)
 {
     $categoryTranslation = $this->categoryTranslationRepository->createNew();
     $categoryTranslation->setLocale($locale);
     $categoryTranslation->setTranslation('');
     $categoryTranslation->setCategory($category);
     $category->addTranslation($categoryTranslation);
     $this->entityManager->persist($categoryTranslation);
     return $categoryTranslation;
 }
Exemple #2
0
 /**
  * Returns category-translation or create a new one.
  *
  * @param CategoryInterface $category
  * @param CategoryWrapper $categoryWrapper
  * @param string $locale
  *
  * @return CategoryTranslationInterface
  */
 private function findOrCreateCategoryTranslation(CategoryInterface $category, CategoryWrapper $categoryWrapper, $locale)
 {
     $translationEntity = $category->findTranslationByLocale($locale);
     if (!$translationEntity) {
         $translationEntity = $this->categoryTranslationRepository->createNew();
         $translationEntity->setLocale($locale);
         $categoryWrapper->setTranslation($translationEntity);
     }
     return $translationEntity;
 }