1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* You can find more information about us on https://bitbag.io and write us |
7
|
|
|
* an email on [email protected]. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace BitBag\SyliusMolliePlugin\Repository; |
13
|
|
|
|
14
|
|
|
use BitBag\SyliusMolliePlugin\Factory\MollieGatewayFactory; |
15
|
|
|
use Sylius\Bundle\CoreBundle\Doctrine\ORM\PaymentMethodRepository as BasePaymentMethodRepository; |
16
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
17
|
|
|
use Sylius\Component\Core\Model\PaymentMethodInterface; |
18
|
|
|
|
19
|
|
|
class PaymentMethodRepository extends BasePaymentMethodRepository implements PaymentMethodRepositoryInterface |
20
|
|
|
{ |
21
|
|
|
public function findAllByFactoryNameAndCode(string $code): array |
22
|
|
|
{ |
23
|
|
|
return $this->createQueryBuilder('o') |
24
|
|
|
->innerJoin('o.gatewayConfig', 'gatewayConfig') |
25
|
|
|
->where('gatewayConfig.factoryName = :factoryName') |
26
|
|
|
->andWhere('o.code != :code') |
27
|
|
|
->setParameter('factoryName', MollieGatewayFactory::FACTORY_NAME) |
28
|
|
|
->setParameter('code', $code) |
29
|
|
|
->getQuery() |
30
|
|
|
->getResult() |
31
|
|
|
; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function findOneByChannelAndGatewayFactoryName(ChannelInterface $channel, $factoryName): ?PaymentMethodInterface |
35
|
|
|
{ |
36
|
|
|
return $this->createQueryBuilder('o') |
37
|
|
|
->innerJoin('o.gatewayConfig', 'gatewayConfig') |
38
|
|
|
->andWhere('o.enabled = true') |
39
|
|
|
->andWhere(':channel MEMBER OF o.channels') |
40
|
|
|
->andWhere('gatewayConfig.factoryName = :factoryName') |
41
|
|
|
->setParameter('channel', $channel) |
42
|
|
|
->setParameter('factoryName', $factoryName) |
43
|
|
|
->addOrderBy('o.position') |
44
|
|
|
->getQuery() |
45
|
|
|
->getOneOrNullResult() |
46
|
|
|
; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|