repository = $repository; } public function clearJsonLabels($json) { $new_data = []; $data = Json::decode($json, true); foreach ($data as $item) { if (isset($item['label'])) { $item['label'] = str_replace( '
', '', $item['label'] ); } $new_data[] = $item; } return Json::encode($new_data, JSON_UNESCAPED_UNICODE); } public function create(FormForm $form): Form { $form = Form::create( $form->name, $this->clearJsonLabels($form->data), $form->subject, $form->from, $form->reply, $form->return, $form->complete_text, $form->complete_page_id, $form->status, $form->captcha ); $this->repository->save($form); FormGenerator::generateFormClass($form->id, Json::decode($form->data, true)); FormGenerator::generateFormView($form->id, Json::decode($form->data, true)); return $form; } public function edit($id, FormForm $form): void { $form_entity = $this->repository->get($id); $form_entity->edit( $form->name, $this->clearJsonLabels($form->data), $form->subject, $form->from, $form->reply, $form->return, $form->complete_text, $form->complete_page_id, $form->status, $form->captcha ); $this->repository->save($form_entity); FormGenerator::generateFormClass($id, Json::decode($form->data, true)); FormGenerator::generateFormView($id, Json::decode($form->data, true)); } public function remove($id): void { $form = $this->repository->get($id); $this->repository->remove($form); } }