Example #1
0
 /**
  * 
  * @param string $object
  * @param string $tag
  */
 public function removeTagAction($object, $tag)
 {
     $iNbDeleted = 0;
     $sLibTag = "tag";
     $repository = $this->repository;
     $sName = $this->objectName;
     $repository::transco($object);
     $aId = $repository::getListBySlugName($object[$sName]);
     if (count($aId) > 0) {
         $object = $aId[0]['id'];
     } else {
         throw new \Exception(static::OBJ_NOT_EXIST, 1);
     }
     $aTags = explode(",", $tag);
     foreach ($aTags as $sTag) {
         $iReturn = TagsRepository::isExist($sTag);
         $bLinked = TagsRepository::isLink($this->objectName, $object, $iReturn);
         if (!$bLinked) {
             throw new \Exception("This tag can't be found on the object", 1);
         }
         TagsRepository::delete($sTag, $this->objectName, $object);
         $iNbDeleted++;
     }
     if ($iNbDeleted > 1) {
         $sLibTag .= "s";
     }
     InputOutput::display($sLibTag . " has been successfully removed from the object", true, 'green');
 }