|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file was created by developers working at BitBag |
|
5
|
|
|
* Do you need more information about us and what we do? Visit our https://bitbag.io website! |
|
6
|
|
|
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace BitBag\SyliusWishlistPlugin\Repository; |
|
12
|
|
|
|
|
13
|
|
|
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; |
|
14
|
|
|
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; |
|
15
|
|
|
use Sylius\Component\Core\Model\ShopUserInterface; |
|
16
|
|
|
|
|
17
|
|
|
class WishlistRepository extends EntityRepository implements WishlistRepositoryInterface |
|
18
|
|
|
{ |
|
19
|
|
|
public function findOneByShopUser(ShopUserInterface $shopUser): ?WishlistInterface |
|
20
|
|
|
{ |
|
21
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
|
|
22
|
|
|
->where('o.shopUser = :shopUser') |
|
23
|
|
|
->setParameter('shopUser', $shopUser) |
|
24
|
|
|
->getQuery() |
|
25
|
|
|
->getOneOrNullResult() |
|
26
|
|
|
; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function findByToken(string $token): ?WishlistInterface |
|
30
|
|
|
{ |
|
31
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
|
|
32
|
|
|
->where('o.token = :token') |
|
33
|
|
|
->setParameter('token', $token) |
|
34
|
|
|
->getQuery() |
|
35
|
|
|
->getOneOrNullResult() |
|
36
|
|
|
; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function findAllByShopUser(int $shopUser): ?array |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
|
|
42
|
|
|
->where('o.shopUser = :shopUser') |
|
43
|
|
|
->setParameter('shopUser', $shopUser) |
|
44
|
|
|
->getQuery() |
|
45
|
|
|
->getResult() |
|
46
|
|
|
; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function findAllByShopUserAndToken(int $shopUser, string $token): ?array |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
|
|
52
|
|
|
->where('o.shopUser = :shopUser') |
|
53
|
|
|
->orWhere('o.token = :token') |
|
54
|
|
|
->setParameter('token', $token) |
|
55
|
|
|
->setParameter('shopUser', $shopUser) |
|
56
|
|
|
->getQuery() |
|
57
|
|
|
->getResult() |
|
58
|
|
|
; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function findAllByAnonymous(?string $token): ?array |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
|
|
64
|
|
|
->where('o.token = :token') |
|
65
|
|
|
->andWhere('o.shopUser IS NULL') |
|
66
|
|
|
->setParameter('token', $token) |
|
67
|
|
|
->getQuery() |
|
68
|
|
|
->getResult() |
|
69
|
|
|
; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|