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