Please explain how the record is updated in database in Symfony/Doctrine?

Study Symfony-3. Generated entity, created form, generated CRUD... For the examples were taken table vendor, consisting of 3 simple fields: id, title, email.

Standard code of a CRUD generator that I'm not clear:
/**
 * Displays a form to edit an existing vendor entity.
*
 * @Route("/{id}/edit", name="vendor_edit")
 * @Method({"GET", "POST"})
*/
 public function editAction(Request $request, Vendor $vendor)
{
 $deleteForm = $this->createDeleteForm($vendor);
 $editForm = $this->createForm('AppBundle\Form\VendorType', $vendor);
$editForm->handleRequest($request);

 if ($editForm->is submitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();

 return $this->redirectToRoute('vendor_edit', array('id' => $vendor->getId()));
}

 return $this->render('vendor/edit.html.twig', array(
 'vendor' => $vendor,
 'edit_form' => $editForm->createView(),
 'delete_form' => $deleteForm->createView(),
));
 }


I do not understand two things:
public function editAction(Request $request, Vendor $vendor)

Here, in addition to query, we also pass the object Vendor. Don't quite understand this logic. If we transferred two forms at once, such as Vendor and User, there would be the same object User and it is automatically assigned to the variable $user? Usually, I need data pulled directly from the variable $request , and appropriated their "hands" where I need (though, the option I like too, of course).

Second not clear moment for me:
if ($editForm->is submitted() && $editForm->isValid()) {
 $this->getDoctrine()->getManager()->flush();


Here the first line is checking if the form is filled, and then there is some kind of magic is not clear to me. We have no variables, but doing the buffer reset. Where Doctrine knows exactly what and where you want to record? I have not found anywhere in the controller code any link the second line of code with some object.

Please explain how this works or if not difficult - stick to the documentation where you could read about it. Thank you!
July 2nd 19 at 17:36
1 answer
July 2nd 19 at 17:38
Solution
If we transferred two forms at once, such as Vendor and User, there would be the User object and it would be automatically assigned to the variable $user? Usually, I need data pulled directly from the variable $request, and appropriated their "hands" where I need (though, the option I like too, of course).

ParamConverter focuses on typehinting in the action parameters, and automatically pulls you to the desired entity from the database according to the parameters of the route.
Here the first line is checking if the form is filled, and then there is some kind of magic is not clear to me. We have no variables, but doing the buffer reset. Where Doctrine knows exactly what and where you want to record?

No magic. Learn how does ORM type Data Mapper. You have the Entity Manager, which "persisted" (persist) certain of the entity. In this case, you have it the entity is in the processing of the form transparent (like behind the scenes) through the so-called DataTransformers.
do a reset of the buffer

In General, a view that is Flush relative to this ORM. For example, here.

Find more questions by tags SymfonyDoctrine ORM