-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make changes to take into account current channel
- Loading branch information
1 parent
94e7f39
commit f1a5168
Showing
9 changed files
with
159 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CommerceWeavers\SyliusTpayPlugin\Repository; | ||
|
||
use Doctrine\ORM\EntityRepository; | ||
use Sylius\Component\Channel\Model\ChannelInterface; | ||
|
||
/** | ||
* @mixin EntityRepository | ||
*/ | ||
trait FindByChannelWithGatewayConfigTrait | ||
{ | ||
public function findByChannelAndGatewayConfigNameWithGatewayConfig(ChannelInterface $channel, string $gatewayConfigName): array | ||
{ | ||
return $this->createQueryBuilder('o') | ||
->addSelect('gatewayConfig') | ||
->leftJoin('o.gatewayConfig', 'gatewayConfig') | ||
->where('o.enabled = :enabled') | ||
->andWhere(':channel MEMBER OF pm.channels') | ||
->andWhere('gatewayConfig.gatewayName = :gatewayName') | ||
->setParameter('enabled', true) | ||
->setParameter('channel', $channel) | ||
->setParameter('gatewayName', $gatewayConfigName) | ||
->getQuery() | ||
->getResult() | ||
; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Repository/FindByChannelWithGatewayConfigTraitInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CommerceWeavers\SyliusTpayPlugin\Repository; | ||
|
||
use Sylius\Component\Channel\Model\ChannelInterface; | ||
use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface as BasePaymentMethodRepositoryInterface; | ||
|
||
interface FindByChannelWithGatewayConfigTraitInterface extends BasePaymentMethodRepositoryInterface | ||
{ | ||
public function findByChannelWithGatewayConfig(ChannelInterface $channel): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/Application/src/Repository/PaymentMethodRepository.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Repository; | ||
|
||
use CommerceWeavers\SyliusTpayPlugin\Repository\FindByChannelWithGatewayConfigTrait; | ||
use Sylius\Bundle\CoreBundle\Doctrine\ORM\PaymentMethodRepository as BasePaymentMethodRepository; | ||
|
||
final class PaymentMethodRepository extends BasePaymentMethodRepository implements PaymentMethodRepositoryInterface | ||
{ | ||
use FindByChannelWithGatewayConfigTrait; | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/Application/src/Repository/PaymentMethodRepositoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Repository; | ||
|
||
use Sylius\Component\Channel\Model\ChannelInterface; | ||
use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface as BasePaymentMethodRepositoryInterface; | ||
|
||
interface PaymentMethodRepositoryInterface extends BasePaymentMethodRepositoryInterface | ||
{ | ||
public function findByChannelAndGatewayConfigNameWithGatewayConfig(ChannelInterface $channel, string $gatewayConfigName): array; | ||
} |
Oops, something went wrong.