From dd58e36910e3765ba5e7362d96b08613995edc30 Mon Sep 17 00:00:00 2001 From: FK Date: Tue, 6 Sep 2022 23:43:46 +0200 Subject: [PATCH] Fix for AppTemplate issue #14 - add null as a possible return type in ShopRepositoryInterface - adjust implementation of ShopRepository to return null if shop by id does not exist - adjust RegistrationService to call create shop in db only if not exist yet --- src/Shop/ShopRepository.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Shop/ShopRepository.php b/src/Shop/ShopRepository.php index aa355bf..35c0ca8 100644 --- a/src/Shop/ShopRepository.php +++ b/src/Shop/ShopRepository.php @@ -33,7 +33,7 @@ public function createShop(ShopInterface $shop): void $queryBuilder->execute(); } - public function getShopFromId(string $shopId): ShopInterface + public function getShopFromId(string $shopId): ?ShopInterface { $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select('shop_id', 'shop_url', 'shop_secret', 'api_key', 'secret_key') @@ -43,6 +43,10 @@ public function getShopFromId(string $shopId): ShopInterface $shop = $queryBuilder->execute()->fetchAssociative(); + if ($shop === false) { + return null; + } + return new ShopEntity( $shop['shop_id'], $shop['shop_url'], @@ -80,4 +84,4 @@ public function deleteShop(ShopInterface $shop): void $queryBuilder->execute(); } -} \ No newline at end of file +}