Skip to content

Commit

Permalink
Merge pull request #171 from BitBagCommerce/OPSRC-672/Validate_creati…
Browse files Browse the repository at this point in the history
…ng_wishlist

Opsrc 672/validate creating wishlist
  • Loading branch information
milwoz authored Aug 24, 2022
2 parents 36c7c84 + dec396b commit 6d6b7fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/CommandHandler/Wishlist/CreateNewWishlistHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public function __invoke(CreateNewWishlist $createNewWishlist): void
$wishlist->setChannel($channel);
}

$wishlists = $this->wishlistRepository->findAllByToken($wishlistCookieToken);
if ($user instanceof ShopUserInterface) {
$wishlists = $this->wishlistRepository->findAllByShopUser($user->getId());
} else {
$wishlists = $this->wishlistRepository->findAllByAnonymous($wishlistCookieToken);
}

/** @var WishlistInterface $wishlist */
foreach ($wishlists as $newWishlist) {
Expand Down
7 changes: 3 additions & 4 deletions src/Repository/WishlistRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function findOneByShopUser(ShopUserInterface $shopUser): ?WishlistInterfa
->getQuery()
->setMaxResults(1)
->getOneOrNullResult()
;
;
}

public function findByToken(string $token): ?WishlistInterface
Expand All @@ -36,7 +36,7 @@ public function findByToken(string $token): ?WishlistInterface
->getQuery()
->setMaxResults(1)
->getOneOrNullResult()
;
;
}

public function findAllByToken(string $token): ?array
Expand Down Expand Up @@ -104,7 +104,7 @@ public function findAllByAnonymousAndChannel(?string $token, ChannelInterface $c
->andWhere('o.channel = :channel')
->andWhere('o.shopUser IS NULL')
->setParameter('channel', $channel)
;
;

if (null !== $token) {
$qb
Expand Down Expand Up @@ -140,5 +140,4 @@ public function findOneByShopUserAndName(ShopUserInterface $shopUser, string $na
->getOneOrNullResult()
;
}

}

0 comments on commit 6d6b7fc

Please sign in to comment.