getEntityManager()->persist($entity); if ($flush) { $this->getEntityManager()->flush(); } } public function delete(AbstractEntity $entity, bool $flush = true): void { $this->getEntityManager()->remove($entity); if ($flush) { $this->getEntityManager()->flush(); } } }