由于Doctrine Tree Extension
我正在使用Alice夹具加载夹具,因此我有一个循环参考例外。
[学说\共同\ DataFixtures \异常\ CircularReferenceException]
图包含循环依赖。这个问题的一个例子是 以下内容:C类将B类作为其依赖关系。然后,B班 A类有其依赖性。最后,A类的C级为 它的依赖性。
我在这里发现了同样的问题: https://github.com/doctrine/data-fixtures/issues/232但解决方案对我不起作用:( ...
我正在使用这个版本的教条。
"doctrine/data-fixtures": "1.2.1",
这是我的实体
namespace BaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* BaseCategory
*
* @ORM\Entity()
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({
* "article_category" = "AppBundle\Entity\ArticleCategory",
* "page_category" = "AppBundle\Entity\PageCategory",
* })
* @Gedmo\Tree(type="nested")
*/
abstract class BaseCategory
{
use \BaseBundle\Traits\SeoTrait;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
* @Assert\NotBlank()
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="slug", type="string", length=255, unique=true)
* @Gedmo\Slug(fields={"title"})
*/
private $slug;
/**
* @var string
*
* @ORM\Column(name="description", type="text")
*/
private $description;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @Gedmo\TreeLeft
* @ORM\Column(type="integer")
*/
private $lft;
/**
* @Gedmo\TreeLevel
* @ORM\Column(type="integer")
*/
private $lvl;
/**
* @Gedmo\TreeRight
* @ORM\Column(type="integer")
*/
private $rgt;
/**
* @Gedmo\TreeRoot
* @ORM\ManyToOne(targetEntity="BaseCategory")
* @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="BaseCategory", inversedBy="children")
* @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="BaseCategory", mappedBy="parent")
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
*
* @return BaseCategory
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set slug
*
* @param string $slug
*
* @return BaseCategory
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set description
*
* @param string $description
*
* @return BaseCategory
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function getRoot()
{
return $this->root;
}
public function setParent(BaseCategory $parent = null)
{
$this->parent = $parent;
}
public function getParent()
{
return $this->parent;
}
}
这是正常的吗?我该如何解决这个问题?