src/Leevel/Database/Ddd/UnitOfWork.php
protected function persistNewEntry(string $position, string $method, IEntity $entity): void
    {
        switch (strtolower($method)) {
            case 'create':
                $this->{'create'.$position}($entity);

                break;
            case 'update':
                $this->{'update'.$position}($entity);

                break;
            case 'replace':
                $this->{'replace'.$position}($entity);

                break;
            case 'save':
            default:
                $ids = $entity->id();

                if (is_array($ids)) {
                    $this->{'replace'.$position}($entity);
                } else {
                    if (empty($ids)) {
                        $this->{'create'.$position}($entity);
                    } else {
                        $this->{'update'.$position}($entity);
                    }
                }

                break;
        }
    }
protected function persistNewEntry(string $position, string $method, IEntity $entity): void
    {
        switch (strtolower($method)) {
            case 'create':
                $this->{'create'.$position}($entity);

                break;
            case 'update':
                $this->{'update'.$position}($entity);

                break;
            case 'replace':
                $this->{'replace'.$position}($entity);

                break;
            case 'save':
            default:
                $ids = $entity->id();

                if (is_array($ids)) {
                    $this->{'replace'.$position}($entity);
                } else {
                    if (empty($ids)) {
                        $this->{'create'.$position}($entity);
                    } else {
                        $this->{'update'.$position}($entity);
                    }
                }

                break;
        }
    }
处理持久化.

@param string                       $position
@param string                       $method
@param \Leevel\Database\Ddd\IEntity $entity