I'm a bit confused about an error that I'm getting:
Undefined method 'getAsArray'. The method name must start with either findBy or findOneBy!
getAsArray() is a method in my repository class, it's called in PostsController.php like so:
$categoriesList = $this->getDoctrine()->getRepository('AirBlogBundle:Category')->getAsArray();
CategoryRepository.php is defined like this:
namespace Air\BlogBundle\Repository;
class CategoryRepository extends TaxonomyRepository
{
}
It extends TaxonomyRepository that lives in the same namespace.
TaxonomyRepository.php is defined like so:
namespace Air\BlogBundle\Repository;
use Doctrine\ORM\EntityRepository;
class TaxonomyRepository extends EntityRepository {
public function getQueryBuilder(array $params = array()) {
$qb = $this->createQueryBuilder('t');
$qb->select('t, COUNT(p.id) as postsCount')
->leftJoin('t.posts', 'p')
->groupBy('t.id');
return $qb;
}
public function getAsArray() {
return $this->createQueryBuilder('t')
->select('t.id, t.name')
->getQuery()
->getArrayResult();
}
}
Why am I getting the "undefined method getAsArray" error?
AirBlogBundle:Taxonomyrepository work?CategoryReposiotry.phpand am still getting the error. Is it possible that the erro is caused by the fact thatPostsController.phplives inAirAdminBundlewhileCategoryReposiotrylives inAirBlogBundle? I'm not sure, I'm referring to the repo withgetRepository('AirBlogBundle:Category')which should find the repository in another bundle.repositoryClassto@ORM\Entityannotation?