Sulu\Bundle\CategoryBundle\Category\KeywordManager::handleOverwrite PHP Метод

handleOverwrite() приватный Метод

Overwrites given keyword.
private handleOverwrite ( Sulu\Bundle\CategoryBundle\Entity\KeywordInterface $keyword, Sulu\Bundle\CategoryBundle\Entity\CategoryInterface $category ) : Keyword
$keyword Sulu\Bundle\CategoryBundle\Entity\KeywordInterface
$category Sulu\Bundle\CategoryBundle\Entity\CategoryInterface
Результат Keyword
    private function handleOverwrite(KeywordInterface $keyword, CategoryInterface $category)
    {
        if (null !== ($synonym = $this->findSynonym($keyword))) {
            // reset entity and remove it from category
            if ($this->entityManager->contains($keyword)) {
                $this->entityManager->refresh($keyword);
            }
            $this->delete($keyword, $category);
            // link this synonym to the category
            $keyword = $synonym;
        }
        $categoryTranslation = $category->findTranslationByLocale($keyword->getLocale());
        if (!$categoryTranslation) {
            $categoryTranslation = $this->createTranslation($category, $keyword->getLocale());
        }
        // if keyword already exists in category
        if ($categoryTranslation->hasKeyword($keyword)) {
            return $keyword;
        }
        $keyword->addCategoryTranslation($categoryTranslation);
        $categoryTranslation->addKeyword($keyword);
        // FIXME category and meta will not be updated if only keyword was changed
        $category->setChanged(new \DateTime());
        $categoryTranslation->setChanged(new \DateTime());
        return $keyword;
    }