I have a problem with my query builder but I do not know how to fix this error can you help me please?
So here is my problem, I want to retrieve the list of questions that are not in my questionnaire and have the same theme as my questionnaire.
Here is my code:
$builder
->add('orderQuestion')
->add('idQuestion', EntityType::class, [
'class' => Question::class,
'query_builder' => function(EntityRepository $er) use ($idTheme, $idQuestionnaire){
$resultatQuestion = $er->createQueryBuilder('questionn')
->select('questionn.id')
->innerJoin('App\Entity\SurveyQuestion', 'surveyQuestion', 'WITH', 'questionn.id = surveyQuestion.idQuestion')
->where('surveyQuestion.idSurvey = :idSurvey')
;
$resultat = $er->createQueryBuilder('q')
->leftJoin('q.surveyQuestions', 'sQ')
->leftJoin('sQ.idSurvey', 's')
->where('q.idTheme = :idTheme')->setParameter('idTheme', $idTheme)->setParameter(':idSurvey', $idQuestionnaire)
->andWhere($er->createQueryBuilder('question')->expr()->notIn('q.id', $resultatQuestion->getDQL()))
;
return $resultat;
},
'choice_label' => function ($question) {
return $question->getLabel();
},
])
;
But, with this code a have this error : "Warning: get_class() expects parameter 1 to be object, array given".
How can I solve this problem ?