Person.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Tree\Fixture\Closure;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @Gedmo\Tree(type="closure")
  7. * @Gedmo\TreeClosure(class="Tree\Fixture\Closure\PersonClosure")
  8. * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\ClosureTreeRepository")
  9. * @ORM\InheritanceType("JOINED")
  10. * @ORM\DiscriminatorColumn(name="discriminator", type="string")
  11. * @ORM\DiscriminatorMap({
  12. "user" = "User"
  13. })
  14. */
  15. class Person
  16. {
  17. /**
  18. * @ORM\Column(name="id", type="integer")
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. */
  22. private $id;
  23. /**
  24. * @ORM\Column(name="full_name", type="string", length=64)
  25. */
  26. private $fullName;
  27. /**
  28. * @Gedmo\TreeParent
  29. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
  30. * @ORM\ManyToOne(targetEntity="Person", inversedBy="children", cascade={"persist"})
  31. */
  32. private $parent;
  33. public function getId()
  34. {
  35. return $this->id;
  36. }
  37. public function setName($name)
  38. {
  39. $this->name = $name;
  40. }
  41. public function getName()
  42. {
  43. return $this->name;
  44. }
  45. public function setParent(Category $parent = null)
  46. {
  47. $this->parent = $parent;
  48. }
  49. public function getParent()
  50. {
  51. return $this->parent;
  52. }
  53. public function addClosure(CategoryClosure $closure)
  54. {
  55. $this->closures[] = $closure;
  56. }
  57. }