I\'m using Symfony 2.7 with Doctrine. My controller actions often look like:
# my/namespace/Controller/ItemsController.php
As other's have said, you should fetch the group Entities inside your repository. You can use something like this:
//inside the repository
public function findAllFetchGroups(){
return $this->createQueryBuilder('a')
->addSelect('gs')->join('a.groups', 'gs')
->getQuery()->getResult();
}
There is two ways to accomplish your target. You can fetch="EAGER" your related data (but it loads always maybe not necessary data) or use query builder to join related collection, it will be loaded in one query. But remember, to keep code clean - no queries outside repositories :)