concrete/src/Entity/User/LoginAttemptRepository.php
public function before(DateTime $before, $user = null, $count = false)
    {
        // Validate and normalize input
        $before = $this->validateTimezone($before);
        $user = $this->validateUser($user);

        // Build the query builder
        $qb = $this->createQueryBuilder('a');

        if ($count) {
            $qb->select('count(a)');
        } else {
            $qb->select();
        }

        $qb->where('a.utcDate < :before')->setParameter('before', $before);

        // Pivot on user id if needed
        if ($user) {
            $qb->andWhere('a.userId=:user')->setParameter('user', $user);
        }

        if ($count) {
            try {
                return $qb->getQuery()->getSingleScalarResult();
            } catch (UnexpectedResultException $e) {
                return 0;
            }
        } else {
            // Return an iterator that contains all login attempts before a given date
            return $qb->getQuery()->iterate();
        }
    }
public function before(DateTime $before, $user = null, $count = false)
    {
        // Validate and normalize input
        $before = $this->validateTimezone($before);
        $user = $this->validateUser($user);

        // Build the query builder
        $qb = $this->createQueryBuilder('a');

        if ($count) {
            $qb->select('count(a)');
        } else {
            $qb->select();
        }

        $qb->where('a.utcDate < :before')->setParameter('before', $before);

        // Pivot on user id if needed
        if ($user) {
            $qb->andWhere('a.userId=:user')->setParameter('user', $user);
        }

        if ($count) {
            try {
                return $qb->getQuery()->getSingleScalarResult();
            } catch (UnexpectedResultException $e) {
                return 0;
            }
        } else {
            // Return an iterator that contains all login attempts before a given date
            return $qb->getQuery()->iterate();
        }
    }
public function before ( DateTime $ before , $ user = null , $ count = false ) { // Validate and normalize input $ before = $ this -> validateTimezone ( $ before ) ; $ user = $ this -> validateUser ( $ user ) ; // Build the query builder $ qb = $ this -> createQueryBuilder ( 'a' ) ; if ( $ count ) { $ qb -> select ( 'count(a)' ) ; } else { $ qb -> select ( ) ; } $ qb -> where ( 'a.utcDate < :before' ) -> setParameter ( 'before' , $ before ) ; // Pivot on user id if needed if ( $ user ) { $ qb -> andWhere ( 'a.userId=:user' ) -> setParameter ( 'user' , $ user ) ; } if ( $ count ) { try { return $ qb -> getQuery ( ) -> getSingleScalarResult ( ) ; } catch ( UnexpectedResultException $ e ) { return 0 ; } } else { // Return an iterator that contains all login attempts before a given date return $ qb -> getQuery ( ) -> iterate ( ) ; } }
Get a list of login attempts prior to a date

@param \DateTime $before Must be in UTC
@param \Concrete\Core\Entity\User\User|int $user
@param bool $count Whether we return an integer count, or an iterator of matches

@return \Iterator|\Concrete\Core\Entity\User\LoginAttempt[]|int
Get a list of login attempts prior to a date