I am encountering the error Undefined method 'findAllCtrs'. The method name must start with either findBy or findOneBy!
I've tried all the other solutions on StackOverflow regarding this problem. I've cleared cache, cleared meta data cache, checked the namespaces and folder entities but still no fix.
Here is my entity:
namespace CFS\Bundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Ref
*
* @ORM\Table(name="ref", indexes={@ORM\Index(name="refno", columns={"refno"}), @ORM\Index(name="ctrno", columns={"ctrno"})})
* @ORM\Entity(repositoryClass="CFS\Bundle\Entity\RefRepository")
*/
class Ref
{
My repository class:
namespace CFS\Bundle\Entity;
use Doctrine\ORM\EntityRepository;
class RefRepository extends EntityRepository
{
public function findAllCtrs()
{
$query = $this->getEntityManager()
->createQuery('
SELECT
r.refno, r.ctrno
FROM
CFSBundle:Ref r
ORDER BY
r.refno DESC
');
try {
return $query->getResult();
} catch(\Doctrine\ORM\NoResultException $e) {
return null;
}
}
}
And I tried calling the method in my controller with:
$em = $this->getDoctrine()->getManager();
$containers = $em->getRepository('CFSBundle:Ref')
->findAllCtrs();
I did noticed that when I generate entities in the command line php app/console doctrine:generate:entities CFSBundle
it is not recognizing my RefRepository.php file. What else could I have missed?