chg: [requestProcessor] Simplified genHTTPReply

pull/41/head
mokaddem 2021-03-19 11:54:43 +01:00
parent 1430647769
commit b52048c760
4 changed files with 7 additions and 12 deletions

View File

@ -120,15 +120,10 @@ class GenericRequestProcessor
];
}
public function genHTTPReply($controller, $processResult, $request, $redirect=null)
public function genHTTPReply($controller, $processResult, $redirect=null)
{
if (is_array($request)) {
$scope = $request['scope'];
$action = $request['action'];
} else {
$scope = $request->scope;
$action = $request->action;
}
$scope = $this->scope;
$action = $this->action;
if ($processResult['success']) {
$message = !empty($processResult['message']) ? $processResult['message'] : __('Request {0} successfully processed.', $id);
if ($controller->ParamHandler->isRest()) {

View File

@ -171,6 +171,6 @@ class BroodsController extends AppController
],
];
$processorResult = $processor->create($data);
return $processor->genHTTPReply($this, $processorResult, ['scope' => 'Brood', 'action' => 'ToolInterconnection'], ['controller' => 'Broods', 'action' => 'index']);
return $processor->genHTTPReply($this, $processorResult, ['controller' => 'Broods', 'action' => 'index']);
}
}

View File

@ -64,7 +64,7 @@ class InboxController extends AppController
$this->requestProcessor = TableRegistry::getTableLocator()->get('RequestProcessor');
$processor = $this->requestProcessor->getProcessor($request->scope, $request->action);
$discardResult = $processor->discard($id, $request);
return $processor->genHTTPReply($this, $discardResult, $request);
return $processor->genHTTPReply($this, $discardResult);
}
$this->set('deletionTitle', __('Discard request'));
$this->set('deletionText', __('Are you sure you want to discard request #{0}?', $id));
@ -85,7 +85,7 @@ class InboxController extends AppController
$processor = $this->requestProcessor->getProcessor($request->scope, $request->action);
if ($this->request->is('post')) {
$processResult = $processor->process($id, $this->request->getData());
return $processor->genHTTPReply($this, $processResult, $request);
return $processor->genHTTPReply($this, $processResult);
} else {
$this->requestProcessor->render($this, $processor, $request);
}

View File

@ -151,6 +151,6 @@ class UsersController extends AppController
],
];
$processorResult = $processor->create($data);
return $processor->genHTTPReply($this, $processorResult, ['scope' => 'User', 'action' => 'Registration'], ['controller' => 'Inbox', 'action' => 'index']);
return $processor->genHTTPReply($this, $processorResult, ['controller' => 'Inbox', 'action' => 'index']);
}
}