| @@ 130-151 (lines=22) @@ | ||
| 127 | * views = { "default" } |
|
| 128 | * ) |
|
| 129 | */ |
|
| 130 | public function postAction(Request $request) |
|
| 131 | { |
|
| 132 | $manager = $this->get("starkerxp_campaign.manager.template"); |
|
| 133 | try { |
|
| 134 | $entite = new Template(); |
|
| 135 | $form = $this->createForm(TemplateType::class, $entite, ['method' => 'POST']); |
|
| 136 | $form->submit($this->getRequestData($request)); |
|
| 137 | if ($form->isValid()) { |
|
| 138 | $template = $form->getData(); |
|
| 139 | $manager->insert($template); |
|
| 140 | $this->dispatch(Events::TEMPLATE_CREATED, new GenericEvent($entite)); |
|
| 141 | ||
| 142 | return new JsonResponse(["payload" => $this->translate("entity.created", "template")], 201); |
|
| 143 | } |
|
| 144 | } catch (\Exception $e) { |
|
| 145 | $manager->rollback(); |
|
| 146 | ||
| 147 | return new JsonResponse(["payload" => $e->getMessage()], 400); |
|
| 148 | } |
|
| 149 | ||
| 150 | return new JsonResponse(["payload" => $this->getFormErrors($form)], 400); |
|
| 151 | } |
|
| 152 | ||
| 153 | /** |
|
| 154 | * @ApiDoc( |
|
| @@ 131-152 (lines=22) @@ | ||
| 128 | * views = { "default" } |
|
| 129 | * ) |
|
| 130 | */ |
|
| 131 | public function postAction(Request $request) |
|
| 132 | { |
|
| 133 | $manager = $this->get("starkerxp_lead.manager.lead"); |
|
| 134 | try { |
|
| 135 | $entite = new Lead(); |
|
| 136 | $form = $this->createForm(LeadType::class, $entite, ['method' => 'POST']); |
|
| 137 | $form->submit($this->getRequestData($request)); |
|
| 138 | if ($form->isValid()) { |
|
| 139 | $lead = $form->getData(); |
|
| 140 | $manager->insert($lead); |
|
| 141 | $this->dispatch(Events::LEAD_CREATED, new GenericEvent($lead)); |
|
| 142 | ||
| 143 | return new JsonResponse(["payload" => $this->translate("entity.created", "lead")], 201); |
|
| 144 | } |
|
| 145 | } catch (\Exception $e) { |
|
| 146 | $manager->rollback(); |
|
| 147 | ||
| 148 | return new JsonResponse(["payload" => $e->getMessage()], 400); |
|
| 149 | } |
|
| 150 | ||
| 151 | return new JsonResponse(["payload" => $this->getFormErrors($form)], 400); |
|
| 152 | } |
|
| 153 | ||
| 154 | /** |
|
| 155 | * @ApiDoc( |
|
| @@ 143-163 (lines=21) @@ | ||
| 140 | * views = { "default" } |
|
| 141 | * ) |
|
| 142 | */ |
|
| 143 | public function postAction(Request $request) |
|
| 144 | { |
|
| 145 | $manager = $this->get("starkerxp_user.manager.user"); |
|
| 146 | try { |
|
| 147 | $form = $this->createForm(UserType::class, [], ['method' => 'POST']); |
|
| 148 | $form->submit($this->getRequestData($request)); |
|
| 149 | if ($form->isValid()) { |
|
| 150 | $user = $form->getData(); |
|
| 151 | $manager->insert($user); |
|
| 152 | $this->dispatch(Events::USER_CREATED, new GenericEvent($user)); |
|
| 153 | ||
| 154 | return new JsonResponse(["payload" => $this->translate("entity.created", "user")], 201); |
|
| 155 | } |
|
| 156 | } catch (\Exception $e) { |
|
| 157 | $manager->rollback(); |
|
| 158 | ||
| 159 | return new JsonResponse(["payload" => $e->getMessage()], 400); |
|
| 160 | } |
|
| 161 | ||
| 162 | return new JsonResponse(["payload" => $this->getFormErrors($form)], 400); |
|
| 163 | } |
|
| 164 | ||
| 165 | /** |
|
| 166 | * @ApiDoc( |
|