|
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\SyliusShippingExportPlugin\Repository; |
|
12
|
|
|
|
|
13
|
|
|
use BitBag\SyliusShippingExportPlugin\Entity\ShippingExportInterface; |
|
14
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
15
|
|
|
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; |
|
16
|
|
|
|
|
17
|
|
|
class ShippingExportRepository extends EntityRepository implements ShippingExportRepositoryInterface |
|
18
|
|
|
{ |
|
19
|
|
|
public const NEW_STATE_PARAMETER = 'newState'; |
|
20
|
|
|
|
|
21
|
|
|
public const PENDING_STATE_PARAMETER = 'pendingState'; |
|
22
|
|
|
|
|
23
|
|
|
public function createListQueryBuilder(): QueryBuilder |
|
24
|
|
|
{ |
|
25
|
|
|
return $this->createQueryBuilder('o') |
|
26
|
|
|
->leftJoin('o.shipment', 'shipment') |
|
27
|
|
|
; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @inheritdoc |
|
32
|
|
|
*/ |
|
33
|
|
|
public function findAllWithNewState(): array |
|
34
|
|
|
{ |
|
35
|
|
|
trigger_deprecation('bitbag/shipping-export-plugin', '1.6', 'The "%s()" method is deprecated, use "ShippingExportRepository::findAllWithNewOrPendingState" instead.', __METHOD__); |
|
36
|
|
|
|
|
37
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
|
|
38
|
|
|
->where('o.state = :newState') |
|
39
|
|
|
->setParameter(self::NEW_STATE_PARAMETER, ShippingExportInterface::STATE_NEW) |
|
40
|
|
|
->getQuery() |
|
41
|
|
|
->getResult() |
|
42
|
|
|
; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function findAllWithNewOrPendingState(): array |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
|
|
48
|
|
|
->where('o.state = :newState OR o.state = :pendingState') |
|
49
|
|
|
->setParameter(self::NEW_STATE_PARAMETER, ShippingExportInterface::STATE_NEW) |
|
50
|
|
|
->setParameter(self::PENDING_STATE_PARAMETER, ShippingExportInterface::STATE_PENDING) |
|
51
|
|
|
->getQuery() |
|
52
|
|
|
->getResult() |
|
53
|
|
|
; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|