1
我有我的數據庫角色:嘗試從命名空間的appbundle 庫加載類「角色」
AppBundle\Entity\Roles:
type: entity
table: Roles
repositoryClass: AppBundle\Repository\Roles
用於測試目的的空類:
namespace AppBundle\Repository;
use Doctrine\ORM\EntityRepository;
use AppBundle\Entity\Roles;
class RolesRepository extends \Doctrine\ORM\EntityRepository
{
}
和簡單的例子在我的控制器:
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?
任何人都可以幫助我嗎?