I don't understand a small part of the doctrine documentation. Part of the documentation :
Generated entity identifiers / primary keys are guaranteed to be available after the next successful flush operation that involves the entity in question. You can not rely on a generated identifier to be available directly after invoking persist. The inverse is also true. You can not rely on a generated identifier being not available after a failed flush operation.
Does it mean that if I create an entity which has an auto-generated ID and persist
+flush
that entity I can't send the id to an other controller ?
Somethink like :
public function testAction()
{
$fabulous = new User();
$fabulousForm = $this->get('form.factory')->create(FabulousType::class, $fabulous);
if($fabulousForm->isSubmitted() && $fabulousForm->isValid())
{
$fabulousId = $fabulousForm->getData()->getUser()->getId();
$em = $this->getDoctrine()->getManager()->persist($fabulous)->flush();
return $this->redirectToRoute('my_fabulous_route', array('user_id' => fabulousId));
}
}