// somewhere in controller
private function getEntityManager()
{
return \Registry::getInstance()->get('em');
}
/**
* @return \App\Repository\UserRepository
*/
private function getUserRepository()
{
return $getEntityManager()->getRepository('App\Entity\User');
}