Skip to content

Commit

Permalink
[RefundPayment] Introduce custom repository
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Jun 9, 2021
1 parent 371a21c commit 4b25791
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
31 changes: 31 additions & 0 deletions src/Doctrine/ORM/RefundPaymentRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\RefundPlugin\Doctrine\ORM;

use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\RefundPlugin\Repository\RefundPaymentRepositoryInterface;

class RefundPaymentRepository extends EntityRepository implements RefundPaymentRepositoryInterface
{
public function findByOrderNumber(string $orderNumber): array
{
return $this->createQueryBuilder('o')
->innerJoin('o.order', 'ord')
->andWhere('ord.number = :orderNumber')
->setParameter('orderNumber', $orderNumber)
->getQuery()
->getResult()
;
}
}
21 changes: 21 additions & 0 deletions src/Repository/RefundPaymentRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\RefundPlugin\Repository;

use Sylius\Component\Resource\Repository\RepositoryInterface;

interface RefundPaymentRepositoryInterface extends RepositoryInterface
{
public function findByOrderNumber(string $orderNumber): array;
}
4 changes: 2 additions & 2 deletions src/Resources/config/admin_routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ sylius_refund_order_refund_payment_list:
_sylius:
template: "@SyliusRefundPlugin/Order/Admin/RefundPayment/list.html.twig"
repository:
method: findByOrder
arguments: expr:service('sylius.repository.order').findOneByNumber($orderNumber)
method: findByOrderNumber
arguments: $orderNumber

sylius_refund_complete_refund_payment:
path: /orders/{orderNumber}/refund-payments/{id}/complete
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ sylius_resource:
sylius_refund.refund_payment:
classes:
model: Sylius\RefundPlugin\Entity\RefundPayment
repository: Sylius\RefundPlugin\Doctrine\ORM\RefundPaymentRepository

sylius_mailer:
emails:
Expand Down

0 comments on commit 4b25791

Please sign in to comment.