_em->persist($entity); if ($flush) { $this->_em->flush(); } } /** * @throws ORMException * @throws OptimisticLockException */ public function remove( $entity, bool $flush = true): void { $this->_em->remove($entity); if ($flush) { $this->_em->flush(); } } }