16

2つのバンドルがあり、1つのCMSバンドルが親バンドルになります。両方のバンドルに重複したエンティティがあります。UserCMSバンドルのユーザーのように、私はそれを抽象クラスにしました。(それが正しい選択であるかどうかはわかりません。実際、私が欲しいのは、必要に応じてユーザーエンティティを拡張することです。)

cmsユーザー:

abstract class User implements UserInterface

バンドルユーザー:

use MV\CMSBundle\Entity\User as BaseUser;

/**
 * @ORM\Entity(repositoryClass="MV\NameBundle\Repository\UserRepository")
 * @DoctrineAssert\UniqueEntity(fields={"email"}, message="user.email.already.exist" )
 */
class User extends BaseUser
{
    ....
}

エラーが発生しましたClass "MV\CMSBundle\Entity\User" is not a valid entity or mapped super class.

symfonyのドキュメントを検索して、次のページを見つけました:entities-entity-mappingしかし、コンテンツxDを追加しませんでした

ああ、いいえ、FOSUserBundleは使いたくありません;)

symfony:2.1

4

4 に答える 4

29

私の場合* @ORM\Entity、クラス定義がありませんでした。

/**
 * @ORM\Entity
 * @ORM\Table(name="listtype")
 */
class ListType
{
    ...
}
于 2013-02-11T18:01:45.853 に答える
26

基本クラスを次のように定義します。

/**
 * @ORM\MappedSuperclass
 */
abstract class BaseUser
{
    // ...
}

実体を定義します。

/**
 * @ORM\Entity
 */
class User extends BaseUser
{
    // ...
}

基本クラスに@MappedSuperclassアノテーションがないため、Doctrineはあなたが言及した例外をスローします。

于 2013-02-02T14:46:43.207 に答える
5

In my case, the problem was eaccelerator because it strips out all the comments which Doctrine uses. After disabling eaccelerator it worked . You can disable your php settings or,

in the web/app_dev.php or web/app.php file.

<?php
    ini_set('eaccelerator.enable', 0);
    ini_set('eaccelerator.optimizer', 0);
    //rest of the code.

Note: Do clear the symfony2 cache after disabling this.

于 2013-02-10T20:22:08.917 に答える
5

I had the same problem. But to make it work but, I had to shift the lines:

* @ORM\Table
* @ORM\Entity 
于 2013-11-18T08:17:22.670 に答える