Slide 41
Slide 41 text
@dunglas
Edit Controller
#[Route('/{id}/edit')]
public function edit(Request $request, Conference $conference, HubInterface $hub): Response
{
$form = $this->createForm(ConferenceType::class, $conference);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// …
$hub->publish(
new Update(
'conference:'.$conference->getId(),
$this->renderView(
'conference/edit.stream.html.twig', ['conference' => $conference]
)
)
);
return $this->redirectToRoute('conference_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm(
'conference/edit.html.twig',
['conference' => $conference, 'form' => $form]
);
}