3

2 つのエンティティを持つ 2 つのバンドルがあります。これらのエンティティ間に manyToMany 関係を作成する必要があります。

財産:

namespace Pfwd\AdminBundle\PropertyBundle\Entity;

use Pfwd\UserBundle\Entity\User as User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="property")
 */
class Property {

//...
/**
 * @ORM\ManyToMany(targetEntity="User")
 * @ORM\JoinTable(name="user_role",
 *     joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
 *     inverseJoinColumns={@ORM\JoinColumn(name="property_id", referencedColumnName="id")}
 * )
 *
 * @var ArrayCollection $salesAgents
 */
protected $salesAgents;

//..

ユーザー:

namespace Pfwd\UserBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="user")
 */
class User implements UserInterface
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     * 
     * @var integer $id
     */
    protected $id;

   // ...

プロパティ バンドルは、ユーザー バンドルに依存します。

私が走るとき

 php app/console doctrine:schema:update --force

次のエラーが表示されます。

 [ErrorException]                                                             
Warning: class_parents(): Class Pfwd\AdminBundle\PropertyBundle\Entity\User  
does not exist and could not be loaded in <SITE_PATH>/symfony2/vendor/doctrine/lib/Doctrine/ORM/Mapping/Cl  
assMetadataFactory.php line 223   

何か案は?

4

1 に答える 1

2

Propertyクラス定義に従って、とのManyToMany関係を定義しましたUser。名前空間を省略したため、現在の名前空間が使用されます。

Userに翻訳されますPfwd\AdminBundle\PropertyBundle\Entity\User

FQCNを指定する必要があります。

@ORM\ManyToMany(targetEntity="Pfwd\UserBundle\Entity\User")
于 2012-07-31T08:23:57.130 に答える