Inheritance: extends Sulu\Component\Persistence\Model\AuditableInterface
Example #1
0
 /**
  * {@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;
 }
Example #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;
 }