现有类的Doctrine Mapping Exception

时间:2014-05-11 05:14:04

标签: php symfony doctrine-orm

我正在使用Symfony 2.4,Sonata Admin和Fos User Bundle。尝试访问登录表单屏幕时,出现此错误:

MappingException: Class 'Telefonica\SIGREH\CoreBundle\Entity\Usuario' does not exist 

但是,当执行php app / console doctrine:mapping:info时,我得到了这个输出:

Found 14 mapped entities:
[OK]   FOS\UserBundle\Entity\Group
[OK]   FOS\UserBundle\Entity\User
[OK]   Sonata\UserBundle\Entity\BaseGroup
[OK]   Sonata\UserBundle\Entity\BaseUser
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Cargo
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Departamento
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Horario
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Motivo
[OK]   Telefonica\SIGREH\CoreBundle\Entity\NivelAcademico
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Oficina
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Region
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Requisicion
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Telefono
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Usuario

我的实体的命名空间是正确的,我已经多次检查过了。

在我的config.yml中,我有以下几行:

sonata_admin:
    security:
        handler: sonata.admin.security.handler.noop

sonata_user:
    manager_type: orm

fos_user:
    db_driver: orm
    firewall_name: admin
    user_class: Telefonica\SIGREH\CoreBundle\Entity\Usuario
    service:
        user_manager: sonata.user.orm.user_manager

在我的AppKernel.php中,我添加了;

new FOS\UserBundle\FOSUserBundle(),

new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\UserBundle\SonataUserBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),

new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),

// Then add SonataAdminBundle
new Sonata\AdminBundle\SonataAdminBundle(),

new Telefonica\SIGREH\CoreBundle\TelefonicaSIGREHCoreBundle(),

Usuario实体如下所示:

<?php

namespace Telefonica\SIGREH\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Entity\User as BaseUser;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="usuario")
 */
class Usuario extends BaseUser
{
    /**
    * @ORM\Id
    * @ORM\Column(type="integer")
    * @ORM\GeneratedValue(strategy="AUTO")
    */
    protected $id;

    /**
     * @var string
     * 
     * @ORM\Column(name="nombre", type="string", length=50, nullable=true)
     * 
     * @Assert\Length(max=50)
     * @Assert\NotBlank
     */
     protected $nombre;

    /**
     * @var string
     * 
     * @ORM\Column(name="apellido", type="string", length=50, nullable=true)
     * @Assert\Length(max=50)
     * 
     */
     protected $apellido;

    public function __construct() {
        parent::__construct();
    }
 }

问题是我做错了什么?

0 个答案:

没有答案