src/Repository/TaskRepository.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\Task;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. /**
  7.  * @method Task|null find($id, $lockMode = null, $lockVersion = null)
  8.  * @method Task|null findOneBy(array $criteria, array $orderBy = null)
  9.  * @method Task[]    findAll()
  10.  * @method Task[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11.  */
  12. class TaskRepository extends ServiceEntityRepository
  13. {
  14.     public function __construct(ManagerRegistry $registry)
  15.     {
  16.         parent::__construct($registryTask::class);
  17.     }
  18.     /**
  19.      * @return Task[] Returns an array of Task objects
  20.      */
  21.     public function getLatestTasks($results 10): array
  22.     {
  23.         return $this->createQueryBuilder('t')
  24.             ->orderBy('t.id''DESC')
  25.             ->setMaxResults($results)
  26.             ->getQuery()
  27.             ->getResult()
  28.         ;
  29.     }
  30.     /**
  31.      * @return Task[] Returns an array of Task objects
  32.      */
  33.     
  34.     public function findByOngoing()
  35.     {
  36.         return $this->createQueryBuilder('t')
  37.         ->andWhere('t.status IN(:statuses)')
  38.         ->setParameter('statuses', [Task::STATUS_CREATEDTask::STATUS_EXECUTING])
  39.             ->orderBy('t.id''ASC')
  40.             ->setMaxResults(10)
  41.             ->getQuery()
  42.             ->getResult()
  43.         ;
  44.     }
  45.     /*
  46.     public function findOneBySomeField($value): ?Task
  47.     {
  48.         return $this->createQueryBuilder('t')
  49.             ->andWhere('t.exampleField = :val')
  50.             ->setParameter('val', $value)
  51.             ->getQuery()
  52.             ->getOneOrNullResult()
  53.         ;
  54.     }
  55.     */
  56. }