fix: [API] taxonomy/addTag now correctly responds if queried via the API instead of redirecting, fixes #4865

pull/4939/head
iglocska 2019-07-29 17:01:28 +02:00
parent e60f0beff9
commit b2e9bbd7ef
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 10 additions and 2 deletions

View File

@ -262,9 +262,17 @@ class TaxonomiesController extends AppController
$result = $this->Taxonomy->addTags($this->request->data['Tag']['taxonomy_id'], $this->request->data['Tag']['nameList']);
}
if ($result) {
$this->Flash->success(__('The tag(s) has been saved.'));
$message = __('The tag(s) has been saved.');
if ($this->_isRest()) {
return $this->RestResponse->saveSuccessResponse('Taxonomy', 'addTag', $taxonomy_id, $this->response->type(), $message);
}
$this->Flash->success($message);
} else {
$this->Flash->error(__('The tag(s) could not be saved. Please, try again.'));
$message = __('The tag(s) could not be saved. Please, try again.');
if ($this->_isRest()) {
return $this->RestResponse->saveFailResponse('Taxonomy', 'addTag', $taxonomy_id, $message, $this->response->type());
}
$this->Flash->error($message);
}
$this->redirect($this->referer());
}