public function onFlush(OnFlushEventArgs $event)
    {
        $uow = $event->getEntityManager()->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            if ($entity instanceof DataInterface
                && $this->hasCreatedEntity(
                    $entity->getFamily(),
                    $entity->getIdentifier()
                )
            ) {
                $this->removeCreatedEntity($entity->getFamily(), $entity->getIdentifier());
            }
        }
    }