From a348f89a4e057438c27482007fd99d3662712bd8 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Tue, 17 Sep 2024 08:32:24 -0500 Subject: [PATCH] Fix UUID keyGen --- docker-compose-image.yml | 34 ------------------------------- src/Repository/BaseRepository.php | 6 ++++-- 2 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 docker-compose-image.yml diff --git a/docker-compose-image.yml b/docker-compose-image.yml deleted file mode 100644 index 7a3dd91..0000000 --- a/docker-compose-image.yml +++ /dev/null @@ -1,34 +0,0 @@ -version: '3.2' -services: - rest: - image: resttest:dev - container_name: resttest - build: - context: . - dockerfile: docker/Dockerfile - ports: - - "8080:80" - environment: - - APP_ENV=dev - networks: - - net - - mysql-container: - image: mysql:8.0 - container_name: mysql-container - environment: - MYSQL_ROOT_PASSWORD: mysqlp455w0rd - TZ: UTC - volumes: - - mysql-volume:/var/lib/mysql - ports: - - "3306:3306" - networks: - - net - -volumes: - mysql-volume: - -networks: - net: - diff --git a/src/Repository/BaseRepository.php b/src/Repository/BaseRepository.php index 7fd8802..5b68d6f 100644 --- a/src/Repository/BaseRepository.php +++ b/src/Repository/BaseRepository.php @@ -203,8 +203,10 @@ public function save($model, ?UpdateConstraint $updateConstraint = null) $primaryKey = $this->repository->getMapper()->getPrimaryKey()[0]; - if ($model->{"get$primaryKey"}() instanceof Literal) { - $model->{"set$primaryKey"}(HexUuidLiteral::getUuidFromLiteral($model->{"get$primaryKey"}())); + if ($model->{"get$primaryKey"}() instanceof HexUuidLiteral) { + /** @var HexUuidLiteral $literal */ + $literal = $model->{"get$primaryKey"}(); + $model->{"set$primaryKey"}($literal->formatUuid()); } return $model;