Fixing style errors.

This commit is contained in:
stickler-ci 2019-11-12 17:10:20 +00:00
parent 480ac1a926
commit fcb50841cc

View File

@ -264,17 +264,17 @@ class Categories extends DolibarrApi
)
);
}
/**
* Link an object to a category by id
*
* @param int $id ID of category
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @param int $object_id ID of object
*
*
* @return array
* @throws RestException
*
*
* @url POST {id}/objects/{type}/{object_id}
*/
public function link_object_by_id($id, $type, $object_id)
@ -282,17 +282,17 @@ class Categories extends DolibarrApi
if (empty($type) || empty($object_id)) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
throw new RestException(404, 'category not found');
}
# TODO Add all types
// TODO Add all types
if ($type === "product") {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
@ -301,7 +301,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(401, "this type is not recognized yet.");
}
if (!empty($object)) {
$result = $object->fetch($object_id);
if ($result > 0) {
@ -314,7 +314,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
}
return array(
'success' => array(
'code' => 200,
@ -322,10 +322,10 @@ class Categories extends DolibarrApi
)
);
}
throw new RestException(401);
}
/**
* Link an object to a category by ref
*
@ -343,17 +343,17 @@ class Categories extends DolibarrApi
if (empty($type) || empty($object_ref)) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
throw new RestException(404, 'category not found');
}
# TODO Add all types
// TODO Add all types
if ($type === "product") {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
@ -362,7 +362,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(401, "this type is not recognized yet.");
}
if (!empty($object)) {
$result = $object->fetch('', $object_ref);
if ($result > 0) {
@ -375,7 +375,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
}
return array(
'success' => array(
'code' => 200,
@ -383,10 +383,10 @@ class Categories extends DolibarrApi
)
);
}
throw new RestException(401);
}
/**
* Unlink an object from a category by id
*
@ -404,17 +404,17 @@ class Categories extends DolibarrApi
if (empty($type) || empty($object_id)) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
throw new RestException(404, 'category not found');
}
# TODO Add all types
// TODO Add all types
if ($type === "product") {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
@ -423,7 +423,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(401, "this type is not recognized yet.");
}
if (!empty($object)) {
$result = $object->fetch((int) $object_id);
if ($result > 0) {
@ -434,7 +434,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
}
return array(
'success' => array(
'code' => 200,
@ -442,10 +442,10 @@ class Categories extends DolibarrApi
)
);
}
throw new RestException(401);
}
/**
* Unlink an object from a category by ref
*
@ -463,17 +463,17 @@ class Categories extends DolibarrApi
if (empty($type) || empty($object_ref)) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
throw new RestException(404, 'category not found');
}
# TODO Add all types
// TODO Add all types
if ($type === "product") {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
@ -482,7 +482,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(401, "this type is not recognized yet.");
}
if (!empty($object)) {
$result = $object->fetch('', (string) $object_ref);
if ($result > 0) {
@ -493,7 +493,7 @@ class Categories extends DolibarrApi
} else {
throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
}
return array(
'success' => array(
'code' => 200,
@ -501,7 +501,7 @@ class Categories extends DolibarrApi
)
);
}
throw new RestException(401);
}