Refactor Forms::trash() to use Doctrine

[MAILPOET-3039]
This commit is contained in:
Rodrigo Primo
2021-04-01 15:03:56 -03:00
committed by Veljko V
parent 86fa574ce8
commit e054f05222
4 changed files with 53 additions and 8 deletions

View File

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