Code Duplication    Length = 20-21 lines in 2 locations

src/Starkerxp/CampaignBundle/Controller/EventController.php 1 location

@@ 132-151 (lines=20) @@
129
     *      views = { "default" }
130
     * )
131
     */
132
    public function postAction(Request $request)
133
    {
134
        $manager = $this->get("starkerxp_campaign.manager.event");
135
        try {
136
            $event = new Event();
137
            $form = $this->createForm(EventType::class, $event, ['method' => 'POST']);
138
            $form->submit($this->getRequestData($request));
139
            if ($form->isValid()) {
140
                $event = $form->getData();
141
                $event->setUuid($this->getUuid());
142
                $manager->insert($event);
143
                return new JsonResponse(["payload" => $this->translate("event.entity.created", "event")], 201);
144
            }
145
        } catch (\Exception $e) {
146
            $manager->rollback();
147
            return new JsonResponse(["payload" => $e->getMessage()], 400);
148
        }
149
150
        return new JsonResponse(["payload" => $this->getFormErrors($form)], 400);
151
    }
152
153
	/**
154
     * @ApiDoc(

src/Starkerxp/UserBundle/Controller/UserController.php 1 location

@@ 141-161 (lines=21) @@
138
     *      views = { "default" }
139
     * )
140
     */
141
    public function postAction(Request $request)
142
    {
143
        $manager = $this->get("starkerxp_user.manager.user");
144
        try {
145
            $form = $this->createForm(UserType::class, [], ['method' => 'POST']);
146
            $form->submit($this->getRequestData($request));
147
            if ($form->isValid()) {
148
                $user = $form->getData();
149
                $user->setUuid($this->getUuid());
150
                $manager->insert($user);
151
152
                return new JsonResponse(["payload" => $this->translate("user.entity.created", "user")], 201);
153
            }
154
        } catch (\Exception $e) {
155
            $manager->rollback();
156
157
            return new JsonResponse(["payload" => $e->getMessage()], 400);
158
        }
159
160
        return new JsonResponse(["payload" => $this->getFormErrors($form)], 400);
161
    }
162
163
    /**
164
     * @ApiDoc(