src/Repository/ArticleRepository.php
/**
     * Find last active and important articles with a limit.
     *
     * @throws Exception dateTime Emits Exception in case of an error
     */
Find last active and important articles with a limit.
@throws Exception dateTime Emits Exception in case of an error
Find last active and important articles with a limit . @throws Exception dateTime Emits Exception in case of an error
public function findLatestImportant(int $limit = null): DoctrinePaginator
    {
        $qb = $this->createQueryBuilder('a')
            ->addSelect('u')
            ->innerJoin('a.user', 'u')
            ->andWhere('a.createdAt <= :now')
            ->andWhere('a.isActive = :status')
            ->addOrderBy('a.priority', 'DESC')
            ->addOrderBy('a.createdAt', 'DESC')
            ->setParameter('now', $this->clock->getNowInDateTime())
            ->setParameter('status', true)
        ;
        if (null !== $limit) {
            $qb->setMaxResults($limit);
        }
        return new DoctrinePaginator($qb);
    }
public function findLatestImportant ( int $ limit = null ) : DoctrinePaginator { $ qb = $ this -> createQueryBuilder ( 'a' ) -> addSelect ( 'u' ) -> innerJoin ( 'a.user' , 'u' ) -> andWhere ( 'a.createdAt <= :now' ) -> andWhere ( 'a.isActive = :status' ) -> addOrderBy ( 'a.priority' , 'DESC' ) -> addOrderBy ( 'a.createdAt' , 'DESC' ) -> setParameter ( 'now' , $ this -> clock -> getNowInDateTime ( ) ) -> setParameter ( 'status' , true ) ; if ( null !== $ limit ) { $ qb -> setMaxResults ( $ limit ) ; } return new DoctrinePaginator ( $ qb ) ; }
Find last active and important articles with a limit.
Find last active and important articles with a limit .