Refactor Forms::restore() to use Doctrine

[MAILPOET-3039]
This commit is contained in:
Rodrigo Primo
2021-04-02 11:23:07 -03:00
committed by Veljko V
parent e054f05222
commit 49f0c054fd
4 changed files with 30 additions and 9 deletions

View File

@ -271,14 +271,12 @@ class Forms extends APIEndpoint {
}
public function restore($data = []) {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form = Form::findOne($id);
if ($form instanceof Form) {
$form->restore();
$form = Form::findOne($form->id);
if(!$form instanceof Form) return $this->errorResponse();
$form = $this->getForm($data);
if ($form instanceof FormEntity) {
$this->formsRepository->restore($form);
return $this->successResponse(
$form->asArray(),
$form->toArray(),
['count' => 1]
);
} else {