src/Sulu/Bundle/CategoryBundle/Category/KeywordManager.php
private function handleDetach(KeywordInterface $keyword, CategoryInterface $category)
    {
        $keywordString = $keyword->getKeyword();
        $keywordLocale = $keyword->getLocale();

        // if keyword wont be deleted (because of multiple references)
        // refresh it to be sure hat changes wont be written to
        // database.
        $this->entityManager->refresh($keyword);

        // delete old keyword from category
        $this->delete($keyword, $category);

        // create new keyword
        $newEntity = $this->keywordRepository->createNew();
        $newEntity->setKeyword($keywordString);
        $newEntity->setLocale($keywordLocale);

        // add new keyword to category
        return $this->save($newEntity, $category);
    }
private function handleDetach(KeywordInterface $keyword, CategoryInterface $category)
    {
        $keywordString = $keyword->getKeyword();
        $keywordLocale = $keyword->getLocale();

        // if keyword wont be deleted (because of multiple references)
        // refresh it to be sure hat changes wont be written to
        // database.
        $this->entityManager->refresh($keyword);

        // delete old keyword from category
        $this->delete($keyword, $category);

        // create new keyword
        $newEntity = $this->keywordRepository->createNew();
        $newEntity->setKeyword($keywordString);
        $newEntity->setLocale($keywordLocale);

        // add new keyword to category
        return $this->save($newEntity, $category);
    }
private function handleDetach ( KeywordInterface $ keyword , CategoryInterface $ category ) { $ keywordString = $ keyword -> getKeyword ( ) ; $ keywordLocale = $ keyword -> getLocale ( ) ; // if keyword wont be deleted (because of multiple references) // refresh it to be sure hat changes wont be written to // database. $ this -> entityManager -> refresh ( $ keyword ) ; // delete old keyword from category $ this -> delete ( $ keyword , $ category ) ; // create new keyword $ newEntity = $ this -> keywordRepository -> createNew ( ) ; $ newEntity -> setKeyword ( $ keywordString ) ; $ newEntity -> setLocale ( $ keywordLocale ) ; // add new keyword to category return $ this -> save ( $ newEntity , $ category ) ; }
Detach given and create new keyword entity.

@param CategoryInterface $category
@param KeywordInterface $keyword

@return KeywordInterface
Detach given and create new keyword entity .