2017-10-11 20 views
1

나는 dB에서 내 역할이 내 컨트롤러에서네임 스페이스 AppBundle 저장소에서 클래스 "역할"을로드하려고

namespace AppBundle\Repository; 
use Doctrine\ORM\EntityRepository; 
use AppBundle\Entity\Roles; 

class RolesRepository extends \Doctrine\ORM\EntityRepository 
{ 
} 

간단한 사용 사례 :

테스트 목적으로
AppBundle\Entity\Roles: 
type:  entity 
table:  Roles 
repositoryClass: AppBundle\Repository\Roles 

빈 클래스 :

namespace AppBundle\Controller; 

use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use AppBundle\Entity\Roles; 
class ClientsController extends CommonController 
{ 
    public function newAction(Request $request) 
    { 
     // [...] 
     $role = $this->getDoctrine() 
       ->getRepository('AppBundle:Roles') 
       ->findOneBy(array('role'=>'ROLE_CLIENT')); 
     // [ ...] 
    } 
} 

때 단지 내가 넣어 "repositoryClass을 : \ AppBundle 저장소 \ 역할 \"내 .orm.yml 파일에, 나는 t을 가지고있어 그는 오류 :

Attempted to load class "Roles" from namespace "\AppBundle\Repository". Did you forget a "use" statement for another namespace?

누구든지이 문제를 해결할 수 있습니까?

repositoryClass: AppBundle\Repository\Roles 

이 있어야 할 것입니다 :

답변

4

저장소 (repository) 클래스 이름 대신, AppBundle\Repository\RolesRepository 당신의 엔티티 설정에 너무

repositoryClass: AppBundle\Repository\RolesRepository