Reputation: 245
I have a class named ServiceUser which is declared as follows
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ServiceUser
*
* @ORM\Table(name="serviceuser")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ServiceUserRepository")
*
*/
class ServiceUser
I also have a ServiceUserRepository which has inside it a custom repository method named findAllOrderedByName
namespace AppBundle\Repository;
use Doctrine\ORM\EntityRepository;
/**
* ServiceUserRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ServiceUserRepository extends EntityRepository
{
public function findAllOrderedByName()
{
return $this->getEntityManager()
->createQuery(
'SELECT s FROM AppBundle:ServiceUser s ORDER BY s.officeName ASC'
)
->getResult();
}
}
My problem is that this custom method is not accessible in the ServiceUserController.
I'm trying to do this
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$serviceUsers = $em->getRepository('AppBundle:ServiceUser')->findAllByName();
return $this->render('serviceuser/index.html.twig', array(
'serviceUsers' => $serviceUsers,
));
}
It can see the OOB methods like get findALL() but not my custom method findAllOrderedByName()
Upvotes: 1
Views: 1257
Reputation: 245
thanks to Cerad for pointing me in the direction of clearing the metadata cache.
In case anyone else has the same issue the following command does this
php bin/console doctrine:cache:clear-metadata
Upvotes: 3