fix: [component:CRUD] Correctly inspect the redirect key

pull/93/head
Sami Mokaddem 2021-11-09 09:15:19 +01:00
parent 1feed8ecaf
commit 04ad3be4a6
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 2 additions and 2 deletions

View File

@ -750,7 +750,7 @@ class CRUDComponent extends Component
if ($this->Controller->ParamHandler->isRest()) { if ($this->Controller->ParamHandler->isRest()) {
$this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json'); $this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json');
} elseif ($this->Controller->ParamHandler->isAjax()) { } elseif ($this->Controller->ParamHandler->isAjax()) {
if ($additionalData['redirect']) { // If a redirection occors, we need to make sure the flash message gets displayed if (!empty($additionalData['redirect'])) { // If a redirection occurs, we need to make sure the flash message gets displayed
$this->Controller->Flash->success($message); $this->Controller->Flash->success($message);
} }
$this->Controller->ajaxResponsePayload = $this->RestResponse->ajaxSuccessResponse($this->ObjectAlias, $action, $data, $message, $additionalData); $this->Controller->ajaxResponsePayload = $this->RestResponse->ajaxSuccessResponse($this->ObjectAlias, $action, $data, $message, $additionalData);
@ -762,7 +762,7 @@ class CRUDComponent extends Component
if ($this->Controller->ParamHandler->isRest()) { if ($this->Controller->ParamHandler->isRest()) {
$this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json'); $this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json');
} elseif ($this->Controller->ParamHandler->isAjax()) { } elseif ($this->Controller->ParamHandler->isAjax()) {
if ($additionalData['redirect']) { // If a redirection occors, we need to make sure the flash message gets displayed if (!empty($additionalData['redirect'])) { // If a redirection occors, we need to make sure the flash message gets displayed
$this->Controller->Flash->error($message); $this->Controller->Flash->error($message);
} }
$this->Controller->ajaxResponsePayload = $this->RestResponse->ajaxFailResponse($this->ObjectAlias, $action, $data, $message, !is_null($errors) ? $errors : $data->getErrors()); $this->Controller->ajaxResponsePayload = $this->RestResponse->ajaxFailResponse($this->ObjectAlias, $action, $data, $message, !is_null($errors) ? $errors : $data->getErrors());