Ejemplo n.º 1
0
 public static function newTagInstance($sTagName, $sModelName, $iTaggedItemId)
 {
     $sTagName = StringUtil::normalize($sTagName);
     $oTag = TagPeer::retrieveByName($sTagName);
     if ($oTag === null) {
         $oTag = new Tag();
         $oTag->setName($sTagName);
         $oTag->save();
     }
     $oTagInstance = self::retrieveByPK($oTag->getId(), $iTaggedItemId, $sModelName);
     if ($oTagInstance !== null) {
         throw new Exception("Instance of this tag does already exist");
     }
     $oTagInstance = new TagInstance();
     $oTagInstance->setTag($oTag);
     $oTagInstance->setModelName($sModelName);
     $oTagInstance->setTaggedItemId($iTaggedItemId);
     $oTagInstance->save();
     return $oTagInstance;
 }