src/Leevel/Database/Ddd/UnitOfWork.php
public function getEntityState(IEntity $entity, ?int $defaults = null): int
    {
        $id = spl_object_id($entity);

        if (isset($this->entityStates[$id])) {
            return $this->entityStates[$id];
        }

        if (null !== $defaults) {
            return $defaults;
        }

        if (!$entity->id()) {
            return self::STATE_NEW;
        }

        return self::STATE_DETACHED;
    }
public function getEntityState(IEntity $entity, ?int $defaults = null): int
    {
        $id = spl_object_id($entity);

        if (isset($this->entityStates[$id])) {
            return $this->entityStates[$id];
        }

        if (null !== $defaults) {
            return $defaults;
        }

        if (!$entity->id()) {
            return self::STATE_NEW;
        }

        return self::STATE_DETACHED;
    }
取得实体状态.

@param \Leevel\Database\Ddd\IEntity $entity
@param int                          $defaults

@return int