/** * {@inheritdoc} */ public function delete(KeywordInterface $keyword, CategoryInterface $category) { $categoryTranslation = $category->findTranslationByLocale($keyword->getLocale()); if ($categoryTranslation) { $keyword->removeCategoryTranslation($categoryTranslation); $categoryTranslation->removeKeyword($keyword); // FIXME category and meta will not be updated if only keyword was changed $category->setChanged(new \DateTime()); $categoryTranslation->setChanged(new \DateTime()); } if ($keyword->isReferenced()) { return false; } $this->entityManager->remove($keyword); return true; }
/** * 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; }