Code Duplication    Length = 17-21 lines in 2 locations

src/SWP/Bundle/CoreBundle/Controller/ContainerController.php 1 location

@@ 145-165 (lines=21) @@
142
     *
143
     * @return SingleResourceResponse
144
     */
145
    public function updateAction(Request $request, $uuid)
146
    {
147
        $container = $this->getContainerForUpdate($uuid);
148
        if (!$container) {
149
            throw new NotFoundHttpException('Container with this uuid was not found.');
150
        }
151
152
        $form = $this->createForm(ContainerType::class, $container, [
153
            'method' => $request->getMethod(),
154
        ]);
155
156
        $form->handleRequest($request);
157
        if ($form->isValid()) {
158
            $container = $this->get('swp_template_engine.container.service')
159
                ->updateContainer($container, $form->get('data')->getExtraData());
160
161
            return new SingleResourceResponse($container, new ResponseContext(201));
162
        }
163
164
        return new SingleResourceResponse($form);
165
    }
166
167
    /**
168
     * Link or Unlink resource with Container.

src/SWP/Bundle/CoreBundle/Controller/MenuController.php 1 location

@@ 219-235 (lines=17) @@
216
     *
217
     * @return SingleResourceResponse
218
     */
219
    public function updateAction(Request $request, $id)
220
    {
221
        $objectManager = $this->get('swp.object_manager.menu');
222
        $menu = $this->findOr404($id);
223
224
        $form = $this->createForm(MenuType::class, $menu, ['method' => $request->getMethod()]);
225
        $form->handleRequest($request);
226
227
        if ($form->isValid()) {
228
            $this->get('swp_menu.manager.menu_item')->update($menu);
229
            $objectManager->flush();
230
231
            return new SingleResourceResponse($menu);
232
        }
233
234
        return new SingleResourceResponse($form, new ResponseContext(400));
235
    }
236
237
    private function findOr404($id)
238
    {