5

Doctrines マニュアルの指示に従ってみました: http://docs.doctrine-project.org/en/latest/reference/association-mapping.html#many-to-many-self-referencing

多くのサブページを持つページエンティティをセットアップしようとしていますが、ページの親ページにもアクセスできるようにしたいと考えています。

上記の手順に従って、symfony2 から、セマンティック エラーのために「使用」を設定する必要があると言われました。

私はかなり立ち往生しているので、これを行うために何をすべきかを誰かに教えてもらえますか。

サンプルコードは次のとおりです。

namespace Pages\Bundle\PageBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * Page
 *
 * @ORM\Table(name="Page")
 * @ORM\Entity(repositoryClass="Pages\Bundle\PageBundle\Entity\PageRepository")
 */
class Page
{
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->subPages = new \Doctrine\Common\Collections\ArrayCollection();
        $this->parentPages = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * @ManyToMany(targetEntity="Page", mappedBy="subPages")
     **/
    private $parentPages;

    /**
     * @ManyToMany(targetEntity="Page", inversedBy="parentPages")
     * @JoinTable(name="sub_pages",
     *      joinColumns={@JoinColumn(name="parent_page_id", referencedColumnName="id")},
     *      inverseJoinColumns={@JoinColumn(name="sub_page_id", referencedColumnName="id")}
     *      )
     **/
    private $subPages;

... (他の変数が続きますが、コンテンツ/メタです)

実行時のエラー応答は次のとおりです。

[Semantical Error] The annotation "@ManyToMany" in property
Pages\Bundle\PageBundle\Entity\Page::$parentPages was never imported. Did you maybe forget to add a "use" statement for this annotation?
4

1 に答える 1