Files
MtoRagSystem/src/Repository/IngestProfileRepository.php
2026-02-17 14:12:24 +01:00

46 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\IngestProfile;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Uid\Uuid;
class IngestProfileRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, IngestProfile::class);
}
public function findLatestVersion(): ?IngestProfile
{
return $this->createQueryBuilder('p')
->orderBy('p.version', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
public function findActive(): ?IngestProfile
{
return $this->findOneBy(['active' => true]);
}
public function remove(string $id): void
{
$entity = $this->find($id);
if (!$entity instanceof IngestProfile) {
return;
}
$em = $this->getEntityManager();
$em->remove($entity);
$em->flush();
}
}