SuperSeller3000/src/Infrastructure/Persistence/Repository/DoctrineAttributeMappingRepository.php

47 lines
1.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace App\Infrastructure\Persistence\Repository;
use App\Domain\Channel\AttributeMapping;
use App\Domain\Channel\Repository\AttributeMappingRepositoryInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Uid\Uuid;
final class DoctrineAttributeMappingRepository implements AttributeMappingRepositoryInterface
{
public function __construct(private readonly EntityManagerInterface $em)
{
}
public function findById(Uuid $id): ?AttributeMapping
{
return $this->em->find(AttributeMapping::class, $id);
}
/** @return list<AttributeMapping> */
public function findByPlatformConfig(Uuid $platformConfigId): array
{
/** @var list<AttributeMapping> */
return $this->em->getRepository(AttributeMapping::class)
->createQueryBuilder('m')
->where('IDENTITY(m.platformConfig) = :configId')
->setParameter('configId', $platformConfigId->toRfc4122())
->getQuery()
->getResult();
}
public function save(AttributeMapping $mapping): void
{
$this->em->persist($mapping);
$this->em->flush();
}
public function remove(AttributeMapping $mapping): void
{
$this->em->remove($mapping);
$this->em->flush();
}
}