/** * Saves tags associated with the blog entry ID passed in. Also maps * the tags to the entry. * * @param int $blogEntryID * The blog entry ID to which the tags should be mapped. * * @param array $tags * The array of tags to associate with the blog entry ID. */ protected function _saveTags($blogEntryID, $tags) { //Add any tags from $tags which are unique. $blogEntryTags = new Datasource_Cms_Connect_BlogEntryTags(); if (!empty($tags)) { $blogEntryTags->upsert($tags); } //Delete all associations with the blogentry $blogEntryTagMap = new Datasource_Cms_Connect_BlogEntryTagMap(); $blogEntryTagMap->removeAllMaps($blogEntryID); //Now associate the blog entry with each tag in $tags if (!empty($tags)) { foreach ($tags as $currentTag) { $tagID = $blogEntryTags->getID($currentTag); $blogEntryTagMap->addMap($blogEntryID, $tagID); } } }