public function testDelete()
 {
     TagsRepository::delete(2, 'host', 1);
     $dataset = $this->createXmlDataSet(dirname(__DIR__) . '/data/tags.del.tagshosts.xml')->getTable('cfg_tags_hosts');
     $tableResult = $this->getConnection()->createQueryTable('cfg_tags_hosts', 'SELECT * FROM cfg_tags_hosts');
     $this->assertTablesEqual($dataset, $tableResult);
 }
Example #2
0
 /**
  * Delete a tag
  *
  * @method post
  * @route /tag/delete
  */
 public function deleteAction()
 {
     $di = Di::getDefault();
     $router = $di->get('router');
     $post = $router->request()->paramsPost();
     TagsRepository::delete($post['tagId'], $post['resourceName'], $post['resourceId']);
     return $router->response()->json(array('success' => true));
 }
Example #3
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');
 }