src/Leevel/Database/Ddd/UnitOfWork.php
protected function updateEntity(IEntity $entity): IUnitOfWork
    {
        $this->validateClosed();

        $id = spl_object_id($entity);

        if (!$entity->id()) {
            $e = sprintf('Entity `%s` has no identity for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityDeletes[$id])) {
            $e = sprintf('Deleted entity `%s` cannot be added for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityCreates[$id])) {
            $e = sprintf('Created entity `%s` cannot be added for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityReplaces[$id])) {
            $e = sprintf('Replaced entity `%s` cannot be added for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityUpdates[$id])) {
            $e = sprintf('Entity `%s` cannot be updated for twice.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        $this->entityUpdates[$id] = $entity;
        $this->entityStates[$id] = self::STATE_MANAGED;

        return $this;
    }
protected function updateEntity(IEntity $entity): IUnitOfWork
    {
        $this->validateClosed();

        $id = spl_object_id($entity);

        if (!$entity->id()) {
            $e = sprintf('Entity `%s` has no identity for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityDeletes[$id])) {
            $e = sprintf('Deleted entity `%s` cannot be added for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityCreates[$id])) {
            $e = sprintf('Created entity `%s` cannot be added for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityReplaces[$id])) {
            $e = sprintf('Replaced entity `%s` cannot be added for update.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        if (isset($this->entityUpdates[$id])) {
            $e = sprintf('Entity `%s` cannot be updated for twice.', get_class($entity));

            throw new InvalidArgumentException($e);
        }

        $this->entityUpdates[$id] = $entity;
        $this->entityStates[$id] = self::STATE_MANAGED;

        return $this;
    }
注册更新实体.

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

@return $this