src/Sulu/Bundle/TagBundle/Tag/TagManager.php
public function merge($srcTagIds, $destTagId)
    {
        $srcTags = [];

        $destTag = $this->tagRepository->findTagById($destTagId);
        if (!$destTag) {
            throw new TagNotFoundException($destTagId);
        }

        foreach ($srcTagIds as $srcTagId) {
            $srcTag = $this->tagRepository->findTagById($srcTagId);

            if (!$srcTag) {
                throw new TagNotFoundException($srcTagId);
            }

            $this->em->remove($srcTag);

            $srcTags[] = $srcTag;
        }

        $this->em->flush();

        // throw an tag.merge event
        $event = new TagMergeEvent($srcTags, $destTag);
        $this->eventDispatcher->dispatch(TagEvents::TAG_MERGE, $event);

        return $destTag;
    }
public function merge($srcTagIds, $destTagId)
    {
        $srcTags = [];

        $destTag = $this->tagRepository->findTagById($destTagId);
        if (!$destTag) {
            throw new TagNotFoundException($destTagId);
        }

        foreach ($srcTagIds as $srcTagId) {
            $srcTag = $this->tagRepository->findTagById($srcTagId);

            if (!$srcTag) {
                throw new TagNotFoundException($srcTagId);
            }

            $this->em->remove($srcTag);

            $srcTags[] = $srcTag;
        }

        $this->em->flush();

        // throw an tag.merge event
        $event = new TagMergeEvent($srcTags, $destTag);
        $this->eventDispatcher->dispatch(TagEvents::TAG_MERGE, $event);

        return $destTag;
    }
public function merge ( $ srcTagIds , $ destTagId ) { $ srcTags = [ ] ; $ destTag = $ this -> tagRepository -> findTagById ( $ destTagId ) ; if ( ! $ destTag ) { throw new TagNotFoundException ( $ destTagId ) ; } foreach ( $ srcTagIds as $ srcTagId ) { $ srcTag = $ this -> tagRepository -> findTagById ( $ srcTagId ) ; if ( ! $ srcTag ) { throw new TagNotFoundException ( $ srcTagId ) ; } $ this -> em -> remove ( $ srcTag ) ; $ srcTags [ ] = $ srcTag ; } $ this -> em -> flush ( ) ; // throw an tag.merge event $ event = new TagMergeEvent ( $ srcTags , $ destTag ) ; $ this -> eventDispatcher -> dispatch ( TagEvents :: TAG_MERGE , $ event ) ; return $ destTag ; }
Merges the source tag into the destination tag.
The source tag will be deleted.

@param number $srcTagIds The source tags, which will be removed afterwards
@param number $destTagId The destination tag, which will replace the source tag

@throws Exception\TagNotFoundException

@return TagInterface The new Tag, which is valid for all given tags
Merges the source tag into the destination tag . The source tag will be deleted .