getKind()) { $suggested = $thirdparty->getParent()->getChildren(); } $form = $this->createForm(ThirdpartyFindDuplicateType::class, null, ['suggested' => $suggested]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $thirdparty2 = $form->get('thirdparty')->getData(); $direction = $form->get('direction')->getData(); if ('starting' === $direction) { $params = [ 'thirdparty1_id' => $thirdparty->getId(), 'thirdparty2_id' => $thirdparty2->getId(), ]; } else { $params = [ 'thirdparty1_id' => $thirdparty2->getId(), 'thirdparty2_id' => $thirdparty->getId(), ]; } return $this->redirectToRoute('chill_thirdparty_duplicate_confirm', $params); } return $this->render('@ChillThirdParty/ThirdPartyDuplicate/find_duplicate.html.twig', [ 'thirdparty' => $thirdparty, 'form' => $form->createView(), ]); } /** * @ParamConverter("thirdparty1", options={"id": "thirdparty1_id"}) * @ParamConverter("thirdparty2", options={"id": "thirdparty2_id"}) */ #[Route(path: '/{_locale}/3party/{thirdparty1_id}/duplicate/{thirdparty2_id}/confirm', name: 'chill_thirdparty_duplicate_confirm')] public function confirmAction(ThirdParty $thirdparty1, ThirdParty $thirdparty2, Request $request) { if ($thirdparty1 === $thirdparty2) { throw new \InvalidArgumentException('Can not merge same thirdparty'); } $form = $this->createForm(PersonConfimDuplicateType::class); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->thirdPartyMergeService->merge($thirdparty1, $thirdparty2); return $this->redirectToRoute('chill_crud_3party_3party_view', ['id' => $thirdparty1->getId()]); } return $this->render('@ChillThirdParty/ThirdPartyDuplicate/confirm.html.twig', [ 'thirdparty' => $thirdparty1, 'thirdparty2' => $thirdparty2, 'form' => $form->createView(), ]); } }