1
私はこれらの3つのクラスを、双方向のYAMLマッピングでDoctrine 2 + Symfonyを使って作成しようとしています。symfony/Doctrine2/YAMLに生成されたPHPクラスのマップがありません
エラーは発生しませんが、生成されたエンティティにはUserエンティティの2つの最初のコレクション宣言のみが含まれます。エンティティには、欠落しているリンクの追加、削除、および取得機能もありません。
私は別々にそれぞれのマッピングを生成しようとしましたが、うまく動作します。
Doctrine2の制限はありますか?
生成MyBundle \エンティティ\ User.phpコンストラクタ(トークンクラス用のArrayCollectionが欠落している):
public function __construct()
{
$this->owned = new \Doctrine\Common\Collections\ArrayCollection();
$this->shared = new \Doctrine\Common\Collections\ArrayCollection();
}
Collection.orm.yml:
MyBundle\Entity\Collection:
type: entity
table: collection
id:
collection_id:
type: integer
generator:
strategy: AUTO
fields:
...
manyToOne:
owner:
targetEntity: User
inversedBy: owned
joinColumn:
name: user_id
referencedColumnName: user_id
manyToMany:
shares:
targetEntity: User
inversedBy: shared
joinTable:
name: shares
joinColumns:
collection_id:
referencedColumnName: collection_id
inverseJoinColumns:
user_id:
referencedColumnName: user_id
Token.orm.yml:
MyBundle\Entity\Token:
type: entity
table: token
id:
token_id:
type: integer
generator:
strategy: AUTO
fields:
...
manyToOne:
user:
targetEntity: User
inversedBy: tokens
joinColumn:
name: user_id
referencedColumnName: user_id
User.orm.yml:
MyBundle\Entity\User:
type: entity
table: user
id:
user_id:
type: integer
generator:
strategy: AUTO
fields:
...
oneToMany:
owned:
targetEntity: Collection
mappedBy: owner
oneToMany:
tokens:
targetEntity: Token
mappedBy: user
manyToMany:
shared:
targetEntity: Collection
mappedBy: shares
パーフェクト!私は正しい方法を除いてあらゆる方法でそれをしようとしました。ありがとうございました。 –