Add get knowledgerecord categorie with REST API
This commit is contained in:
parent
6de1f6bbac
commit
8172cb5b97
@ -19,6 +19,7 @@
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
dol_include_once('/knowledgemanagement/class/knowledgerecord.class.php');
|
||||
dol_include_once('/categories/class/categorie.class.php');
|
||||
|
||||
|
||||
|
||||
@ -85,6 +86,39 @@ class KnowledgeManagement extends DolibarrApi
|
||||
return $this->_cleanObjectDatas($this->knowledgerecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get categories for a knowledgerecord object
|
||||
*
|
||||
* @param int $id ID of knowledgerecord object
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @url GET /knowledgerecords/{id}/categories
|
||||
*/
|
||||
public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$categories = new Categorie($this->db);
|
||||
|
||||
$result = $categories->getListForItem($id, 'knowledgemanagement', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.array_merge(array($categories->error), $categories->errors));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* List knowledgerecords
|
||||
|
||||
Loading…
Reference in New Issue
Block a user