Skip to content

Instantly share code, notes, and snippets.

@jonathaningram
Created December 14, 2011 11:04
Show Gist options
  • Save jonathaningram/1476139 to your computer and use it in GitHub Desktop.
Save jonathaningram/1476139 to your computer and use it in GitHub Desktop.
Cannot remove entities then flush on a "Tree" structured entity
<?php
/**
* @Gedmo\Tree(type="nested")
*
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
* @ORM\Table(name="node_tree")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"node" = "Node", "sub_node" = "SubNode"})
* @ORM\HasLifecycleCallbacks
*/
class Node implements MyNodeInterface
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
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 $rgt;
/**
* @Gedmo\TreeRoot
* @ORM\Column(name="root", type="integer", nullable=true)
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="Node", inversedBy="children",cascade={"remove"})
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id",onDelete="set null")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="Node", mappedBy="parent",cascade={"remove"})
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment