我想为我的 Symfony2 应用程序使用 DoctrineExtensions 的树功能。
但我得到这个错误:
Tree object class: MyBundle\Entity\Category must have tree metadata at this point.
Symfony:v2.5.3
共同教义:v2.4.2
教义扩展:大师
<?php
namespace MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* Category
* @Gedmo\Tree(type="nested")
* @ORM\Table(name="category", uniqueConstraints={@ORM\UniqueConstraint(name="id", columns={"id"})})
* use repository for handy tree functions
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
*/
class Category
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @Gedmo\TreeLeft
* @ORM\Column(name="lft", type="integer")
*/
private $lft;
/**
* @Gedmo\TreeLevel
* @ORM\Column(name="lvl", type="integer")
*/
private $lvl;
/**
* @Gedmo\TreeRight
* @ORM\Column(name="rgt", type="integer")
*/
private $rght;
/**
* @Gedmo\TreeRoot
* @ORM\Column(name="root", type="integer", nullable=true)
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
* @ORM\JoinColumn(name="parentId", referencedColumnName="id", onDelete="CASCADE")
*/
private $parentid;
/**
* @ORM\OneToMany(targetEntity="Category", mappedBy="parentid")
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
我按照这个文档在 Symfony2 中安装 Gedmo Doctrine2 扩展,但似乎有问题。