From ec4dff545f13da3c8a8d70602a209d4719d48e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bar=C3=A1=C5=A1ek?= Date: Mon, 7 Feb 2022 21:55:34 +0100 Subject: [PATCH] InvoiceRepository: Implements OrderInvoiceRepository from baraja-core/shop-order --- src/Entity/InvoiceRepository.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Entity/InvoiceRepository.php b/src/Entity/InvoiceRepository.php index cc3521e..825d0ef 100644 --- a/src/Entity/InvoiceRepository.php +++ b/src/Entity/InvoiceRepository.php @@ -5,10 +5,12 @@ namespace Baraja\Shop\Invoice\Entity; +use Baraja\EcommerceStandard\DTO\InvoiceInterface; use Baraja\EcommerceStandard\DTO\OrderInterface; +use Baraja\Shop\Order\Repository\OrderInvoiceRepository; use Doctrine\ORM\EntityRepository; -final class InvoiceRepository extends EntityRepository +final class InvoiceRepository extends EntityRepository implements OrderInvoiceRepository { /** * @return array @@ -25,4 +27,26 @@ public function getByOrder(OrderInterface $order): array return $invoices; } + + + /** + * @param array $ids + * @return array + */ + public function getInvoicesByOrderIds(array $ids): array + { + /** @var array $invoices */ + $invoices = $this->createQueryBuilder('i') + ->where('i.order IN (:ids)') + ->setParameter('ids', $ids) + ->getQuery() + ->getResult(); + + $return = []; + foreach ($invoices as $invoice) { + $return[$invoice->getOrder()->getId()] = $invoice; + } + + return $return; + } }