我有一個簡單的抽象ApiController(從控制器擴展)類,其中我處理身份驗證。Symfony 2.8教條
protected function handleAuth(){
$login = $this->request->getUser();
$password = $this->request->getPassword();
$user = $this->get('doctrine.orm.entity_manager');
if (!$user)
{
return $this->sendResponse(array('msg'=>'User not found'),404);
}
$user = $user[0];
if(!password_verify($data['password'], $user->getUserPass())){
return $this->sendResponse(array('msg'=>'Invalid credentials'),401);
}
return true;
}
但它拋出,在我的抽象控制器越來越學說的erorr:
Error: Call to a member function get() on a non-object
in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 391
我怎麼能在我的抽象類得到的學說?
您是否將抽象ApiController註冊爲服務? – RxV