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?
任何人都可以帮助我吗?