public function fetchTermsForUser(User $user, Vocabulary $vocabulary) { $data = $this->dbal->fetchAll('SELECT t.* FROM taxonomyTerms t JOIN userTags u ON t.id=u.term_id WHERE u.user_id = :user_id AND t.vocabulary_id = :vocabulary_id ', ['vocabulary_id' => $vocabulary->getId(), 'user_id' => $user->getId()]); $terms = []; foreach ($data as $termData) { $term = $this->termHydrator->hydrate($termData, new Term()); $term->setVocabulary($vocabulary); $terms[] = $term; } return $terms; }