2026-05-14 04:31:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Infrastructure\Persistence\Repository;
|
|
|
|
|
|
|
|
|
|
use App\Domain\Order\Customer;
|
|
|
|
|
use App\Domain\Order\Repository\CustomerRepositoryInterface;
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
|
|
|
|
|
|
final class DoctrineCustomerRepository implements CustomerRepositoryInterface
|
|
|
|
|
{
|
feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
public function __construct(private readonly EntityManagerInterface $em)
|
|
|
|
|
{
|
|
|
|
|
}
|
2026-05-14 04:31:33 +00:00
|
|
|
|
|
|
|
|
public function findById(Uuid $id): ?Customer
|
|
|
|
|
{
|
|
|
|
|
return $this->em->find(Customer::class, $id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findByPlatformId(string $platform, string $platformUserId): ?Customer
|
|
|
|
|
{
|
feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
/** @var Customer|null */
|
2026-05-14 04:31:33 +00:00
|
|
|
return $this->em->getRepository(Customer::class)
|
|
|
|
|
->createQueryBuilder('c')
|
feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
->where('JSON_UNQUOTE(JSON_EXTRACT(c.platformIds, :path)) = :id')
|
2026-05-14 04:31:33 +00:00
|
|
|
->setParameter('path', '$."'.$platform.'"')
|
|
|
|
|
->setParameter('id', $platformUserId)
|
|
|
|
|
->setMaxResults(1)
|
|
|
|
|
->getQuery()
|
|
|
|
|
->getOneOrNullResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findByMatchingKey(string $matchingKey): ?Customer
|
|
|
|
|
{
|
|
|
|
|
$customers = $this->em->getRepository(Customer::class)->findAll();
|
|
|
|
|
foreach ($customers as $customer) {
|
|
|
|
|
if ($customer->getMatchingKey() === $matchingKey) {
|
|
|
|
|
return $customer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function save(Customer $customer): void
|
|
|
|
|
{
|
|
|
|
|
$this->em->persist($customer);
|
|
|
|
|
$this->em->flush();
|
|
|
|
|
}
|
|
|
|
|
}
|