Symfony2返回类在实体加载时不存在

时间:2012-05-09 10:40:15

标签: php symfony doctrine-orm

我试图从我的文件实体加载一个对象,但symfony一直在返回 " Class Frontend \ FolderBundle \ Entity \ Role不存在",但我可以从子文件夹实体中使用它而没有任何问题或警告

我有以下实体:

Frontend\FolderBundle\Entity\File:
type: entity
table: file
fields:
id:
  type: integer
  id: true
  generator:
    strategy: AUTO
filename:
  type: text
user:
  type: integer
manyToOne:
folder:
    targetEntity: Frontend\FolderBundle\Entity\Subfolder
    inversedBy: files
    joinColumn:
      name: subfolder_id
      referencedColumnName: id
lifecycleCallbacks: {  }


Frontend\FolderBundle\Entity\Subfolder:
type: entity
table: subfolder
fields:
id:
  type: integer
  id: true
  generator:
    strategy: AUTO
name:
  type: string
  length: 255
manyToOne:
    folder:
        targetEntity: Folder
        inversedBy: subfolder
        joinColumn:
            name: folder_id
            referencedColumnName: id
oneToMany:
    files:
        targetEntity: File
        mappedBy: folder
manyToMany:
roles:
  targetEntity: Frontend\UserBundle\Entity\Role
  inversedBy: subfolders
  joinTable:
    name: folder_rights
    joinColumns:
      subfolder_id:
        referencedColumnName: id
    inverseJoinColumns:
      role_id:
        referencedColumnName: id
lifecycleCallbacks: {  }

从子文件夹获取文件夹所具有的角色工作正常。

我已经清除了app / cache和doctrine缓存,但这并没有解决问题..

如果您需要更多信息/代码片段,请询问,我会提供。

提前致谢,

1 个答案:

答案 0 :(得分:0)

错误发生在Subfolder.php实体中。有一个addRole函数,引用了与正确实体的错误包。