getEntityManager(); $entityManager->persist($role); $entityManager->flush(); } public function deleteRole(Role $role) { $em = $this->getEntityManager(); $em->beginTransaction(); try { $em->remove($role); $em->flush(); $em->commit(); } catch (ORMException $ex) { $em->rollback(); throw $ex; } } }