34 lines
862 B
PHP
34 lines
862 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Infrastructure\Persistence\Repository;
|
||
|
|
|
||
|
|
use App\Domain\Order\Invoice;
|
||
|
|
use App\Domain\Order\Repository\InvoiceRepositoryInterface;
|
||
|
|
use Doctrine\ORM\EntityManagerInterface;
|
||
|
|
use Symfony\Component\Uid\Uuid;
|
||
|
|
|
||
|
|
final class DoctrineInvoiceRepository implements InvoiceRepositoryInterface
|
||
|
|
{
|
||
|
|
public function __construct(private readonly EntityManagerInterface $em)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public function findById(Uuid $id): ?Invoice
|
||
|
|
{
|
||
|
|
return $this->em->find(Invoice::class, $id);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function findByFrappeInvoiceId(string $frappeInvoiceId): ?Invoice
|
||
|
|
{
|
||
|
|
return $this->em->getRepository(Invoice::class)->findOneBy(['frappeInvoiceId' => $frappeInvoiceId]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function save(Invoice $invoice): void
|
||
|
|
{
|
||
|
|
$this->em->persist($invoice);
|
||
|
|
$this->em->flush();
|
||
|
|
}
|
||
|
|
}
|