Code Duplication    Length = 20-21 lines in 2 locations

src/BCRM/WebBundle/Controller/EventController.php 2 locations

@@ 275-294 (lines=20) @@
272
     *
273
     * @Template()
274
     */
275
    public function unregisterAction(Request $request)
276
    {
277
        $form = $this->formFactory->create(new EventUnregisterType());
278
        $form->handleRequest($request);
279
        if ($form->isValid()) {
280
            /* @var EventRegisterModel $formData */
281
            $formData          = $form->getData();
282
            $command           = new UnregisterCommand();
283
            $command->event    = $this->eventRepo->getNextEvent()->getOrThrow(new AccessDeniedHttpException('No event.'));
284
            $command->email    = $formData->email;
285
            $command->saturday = $formData->wantsSaturday();
286
            $command->sunday   = $formData->wantsSunday();
287
            $this->commandBus->handle($command);
288
            return new RedirectResponse($this->router->generate('bcrmweb_unregistration_ok'));
289
        }
290
        return array(
291
            'sponsors' => $this->reader->getPage('Sponsoren/Index.md'),
292
            'form'     => $form->createView(),
293
        );
294
    }
295
296
    public function confirmUnregistrationAction($id, $key)
297
    {
@@ 316-336 (lines=21) @@
313
     * @return array|RedirectResponse
314
     * @Template()
315
     */
316
    public function cancelTicketAction(Request $request, $id, $code)
317
    {
318
        /* @var $ticket Ticket */
319
        $ticket = $this->ticketRepo->getTicketByIdAndCode($id, $code)->getOrThrow(new NotFoundHttpException('Unknown ticket.'));
320
321
        if ($request->isMethod('POST')) {
322
            $command            = new UnregisterCommand();
323
            $command->event     = $this->eventRepo->getNextEvent()->getOrThrow(new AccessDeniedHttpException('No event.'));
324
            $command->email     = $ticket->getEmail();
325
            $command->saturday  = $ticket->isSaturday();
326
            $command->sunday    = $ticket->isSunday();
327
            $command->confirmed = true;
328
            $this->commandBus->handle($command);
329
            return new RedirectResponse($this->router->generate('bcrmweb_unregistration_confirmed'));
330
        }
331
332
        return array(
333
            'ticket'   => $ticket,
334
            'sponsors' => $this->reader->getPage('Sponsoren/Index.md'),
335
        );
336
    }
337
338
    /**
339
     * @return Response