Example #1
0
 $updateDepth = false;
 $updatePathString = false;
 $newParentTag = $mainTag->getParent();
 $db = eZDB::instance();
 $db->begin();
 if ($tag->attribute('depth') != $mainTag->attribute('depth')) {
     $updateDepth = true;
 }
 if ($tag->attribute('parent_id') != $mainTag->attribute('parent_id')) {
     $oldParentTag = $tag->getParent();
     if ($oldParentTag instanceof eZTagsObject) {
         $oldParentTag->updateModified();
     }
     $updatePathString = true;
 }
 eZTagsObject::moveChildren($tag, $mainTag);
 $synonyms = $tag->getSynonyms();
 foreach ($synonyms as $synonym) {
     $synonym->setAttribute('parent_id', $mainTag->attribute('parent_id'));
     $synonym->setAttribute('main_tag_id', $mainTag->attribute('id'));
     $synonym->store();
 }
 $tag->setAttribute('parent_id', $mainTag->attribute('parent_id'));
 $tag->setAttribute('main_tag_id', $mainTag->attribute('id'));
 $tag->store();
 if (!$newParentTag instanceof eZTagsObject) {
     $newParentTag = false;
 }
 if ($updatePathString) {
     $tag->updatePathString($newParentTag);
 }