src/Leevel/Database/Ddd/UnitOfWork.php
protected function removeEntity(string $position, IEntity $entity, int $priority = 500): IUnitOfWork
    {
        $id = spl_object_id($entity);

        $entityState = $this->getEntityState($entity);

        switch ($entityState) {
            case self::STATE_NEW:
            case self::STATE_REMOVED:
                break;
            case self::STATE_MANAGED:
                $this->{'delete'.$position}($entity, $priority);

                break;
             case self::STATE_DETACHED:
             default:
                $e = sprintf('Detached entity `%s` cannot be remove.', get_class($entity));

                throw new InvalidArgumentException($e);
        }

        return $this;
    }
protected function removeEntity(string $position, IEntity $entity, int $priority = 500): IUnitOfWork
    {
        $id = spl_object_id($entity);

        $entityState = $this->getEntityState($entity);

        switch ($entityState) {
            case self::STATE_NEW:
            case self::STATE_REMOVED:
                break;
            case self::STATE_MANAGED:
                $this->{'delete'.$position}($entity, $priority);

                break;
             case self::STATE_DETACHED:
             default:
                $e = sprintf('Detached entity `%s` cannot be remove.', get_class($entity));

                throw new InvalidArgumentException($e);
        }

        return $this;
    }
移除实体.

@param string                       $position
@param \Leevel\Database\Ddd\IEntity $entity
@param int                          $priority

@return $this