refactor: move DQL in repositories

This commit is contained in:
Maël Gangloff
2025-10-21 12:52:43 +02:00
parent 1ae35231fe
commit 4facd7e951
12 changed files with 123 additions and 81 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Repository;
use App\Entity\Domain;
use App\Entity\DomainEntity;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@@ -16,6 +17,18 @@ class DomainEntityRepository extends ServiceEntityRepository
parent::__construct($registry, DomainEntity::class);
}
public function setDomainEntityAsDeleted(Domain $domain)
{
return $this->createQueryBuilder('de')
->update()
->set('de.deletedAt', ':now')
->where('de.domain = :domain')
->andWhere('de.deletedAt IS NOT NULL')
->setParameter('now', new \DateTimeImmutable())
->setParameter('domain', $domain)
->getQuery()->execute();
}
// /**
// * @return DomainEntity[] Returns an array of DomainEntity objects
// */