public function removeResource(EntityInterface $entity, bool $flush = true) { $this->dispatchEvent(self::PRE_ENTITY_REMOVE_EVENT, $entity); $this->getEntityManager()->remove($entity); $this->dispatchEvent(self::POST_ENTITY_REMOVE_EVENT, $entity); if ($flush) { $this->getEntityManager()->flush(); } }