public function new(Request $request, Vacancy $vacancy, ServiceHandler $serviceHandler): Response
{
/** @var User $user */
$user = $this->getUser();
if ($propositionService->checkCountPropositions($user)) {
$this->addFlash('success', 'You have reached the limit of daily Proposition.');
return $this->redirectToRoute('propositions');
}
$dto = new DTO($blablal);
$form = $this->createForm(DtoForm::class, $dto );
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
try {
$serviceHandler->handle($dto); //здесь и просходит всё, что я выкинул из вашего контроллера
$this->addFlash('success', 'Proposition created');
return $this->redirectToRoute('propositions');
} catch (\DomainException $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
$this->addFlash('error', $e->getMessage());
}
}
return $this->render('proposition/new.html.twig', [
'proposition' => $proposition,
'form' => $form->createView(),
]);
}