Exécuter des crons 12 34 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 ——/ src /仓库/ CommentRepository.php+ + + b / src /仓库/ CommentRepository.php@@ -6,6 +6,7 @@使用App\Entity\Comment;使用App \实体\会议;使用原则\ \ DoctrineBundle \ Repository \ ServiceEntityRepository捆绑销售;使用原则\ \ ManagerRegistry持久性;+使用原则\ ORM \ QueryBuilder;使用原则\ ORM工具\ \分页\ Paginator;/** @@ -18,6 +19,8 @@使用Doctrine\ORM\Tools\Pagination\Paginator;*/ class CommentRepository扩展ServiceEntityRepository {+ private const days_before_rejected_remove = 7;+PAGINATOR_PER_PAGE = 2;公共函数__construct(ManagerRegistry $registry) @@ -25,6 +28,29 @@ class CommentRepository extends ServiceEntityRepository parent::__construct($registry, Comment::class);}+公共函数countoldreject (): int+ {+返回$this->getOldRejectedQueryBuilder()->select('COUNT(c.id)')->getQuery()->getSingleScalarResult();+}++公共函数deleteoldreject (): int+ {+返回$this->getOldRejectedQueryBuilder()->delete()->getQuery()->execute();+}++私有函数getOldRejectedQueryBuilder(): QueryBuilder+ {+返回$this->createQueryBuilder('c')+ - >引入(c。State =:state_rejected or c.state =:state_spam')+ - >引入(c。createdAt <:date')+ - > setParameters ([+ 'state_rejected' => 'rejected',+ 'state_spam' => 'spam',+ 'date' => new \DateTimeImmutable(-self::DAYS_BEFORE_REJECTED_REMOVAL。“天”),+))+;+}+getCommentPaginator(Conference $ Conference, int $offset): Paginator {$query = $this->createQueryBuilder('c') 提示 Pour les requêtes + complex, il est parfois实用的网页上的un coup d' euile aux requêtes SQL générées (les se trouvent dans les log et dans le profileur de requêtes web)。