-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathCronJobResultRepository.php
More file actions
31 lines (26 loc) · 902 Bytes
/
CronJobResultRepository.php
File metadata and controls
31 lines (26 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
declare(strict_types=1);
namespace Shapecode\Bundle\CronBundle\Repository;
use DateTimeInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Shapecode\Bundle\CronBundle\Entity\CronJobResult;
/** @extends ServiceEntityRepository<CronJobResult> */
class CronJobResultRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, CronJobResult::class);
}
public function deleteOldLogs(DateTimeInterface $time): void
{
$this->getEntityManager()->createQuery(
<<<'DQL'
DELETE FROM Shapecode\Bundle\CronBundle\Entity\CronJobResult d
WHERE d.createdAt <= :createdAt
DQL,
)
->setParameter('createdAt', $time)
->execute();
}
}