public function getQuestionnairesByUser(UserInterface $user)
    {
        $questionnaires = $this->createQueryBuilder('us')
            ->where('us.user = :user')
            ->setParameter('user', $user)
            ->getQuery()
            ->getResult();

        $resource = array();
        $now = new \DateTime();

        /** @var UserSessionInterface $questionnaire */
        foreach ($questionnaires as $questionnaire) {
            $configuration = $questionnaire->getConfiguration();

            if (!is_null($configuration->getEndAt())) {
                continue;
            }

            if ($configuration->getMaxQuestions() - $configuration->getQuestions()->count() == 0) {
                if (is_null($configuration->getStartAt()) || $configuration->getStartAt() <= $now) {
                    $resource[] = $questionnaire;
                }
            }
        }

        return $resource;
    }
public function getQuestionnairesByUser(UserInterface $user)
    {
        $questionnaires = $this->createQueryBuilder('us')
            ->where('us.user = :user')
            ->setParameter('user', $user)
            ->getQuery()
            ->getResult();

        $resource = array();
        $now = new \DateTime();

        /** @var UserSessionInterface $questionnaire */
        foreach ($questionnaires as $questionnaire) {
            $configuration = $questionnaire->getConfiguration();

            if (!is_null($configuration->getEndAt())) {
                continue;
            }

            if ($configuration->getMaxQuestions() - $configuration->getQuestions()->count() == 0) {
                if (is_null($configuration->getStartAt()) || $configuration->getStartAt() <= $now) {
                    $resource[] = $questionnaire;
                }
            }
        }

        return $resource;
    }
public function getQuestionnairesByUser ( UserInterface $ user ) { $ questionnaires = $ this -> createQueryBuilder ( 'us' ) -> where ( 'us.user = :user' ) -> setParameter ( 'user' , $ user ) -> getQuery ( ) -> getResult ( ) ; $ resource = array ( ) ; $ now = new \ DateTime ( ) ; /** @var UserSessionInterface $questionnaire */ foreach ( $ questionnaires as $ questionnaire ) { $ configuration = $ questionnaire -> getConfiguration ( ) ; if ( ! is_null ( $ configuration -> getEndAt ( ) ) ) { continue ; } if ( $ configuration -> getMaxQuestions ( ) - $ configuration -> getQuestions ( ) -> count ( ) == 0 ) { if ( is_null ( $ configuration -> getStartAt ( ) ) || $ configuration -> getStartAt ( ) <= $ now ) { $ resource [ ] = $ questionnaire ; } } } return $ resource ; }
Get questionnaires by user

@param UserInterface $user

@return mixed|\Pagerfanta\Pagerfanta
Get questionnaires by user