/** * Edits an existing ProtectionUser entity. * * @Route("/{entity}/update", name="config_protectionuser_update") * @Method("POST") * @Template("JeboehmLampcpCoreBundle:ProtectionUser:edit.html.twig") */ public function updateAction(Request $request, ProtectionUser $entity) { $oldPassword = $entity->getPassword(); $editForm = $this->createForm(new ProtectionUserType(), $entity); $editForm->bind($request); if ($editForm->isValid()) { $em = $this->getDoctrine()->getManager(); if (!$entity->getPassword()) { $entity->setPassword($oldPassword); } else { $entity->setPassword($this->_getCryptService()->encrypt($entity->getPassword())); } $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('config_protectionuser_edit', array('entity' => $entity->getId()))); } return array('entity' => $entity, 'edit_form' => $editForm->createView()); }