BaseNode.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace Tree\Fixture;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
  7. * @ORM\InheritanceType("SINGLE_TABLE")
  8. * @ORM\DiscriminatorColumn(name="discriminator", type="string")
  9. * @ORM\DiscriminatorMap({"base" = "BaseNode", "node" = "Node"})
  10. * @Gedmo\Tree(type="nested")
  11. */
  12. class BaseNode extends ANode
  13. {
  14. /**
  15. * @Gedmo\TreeParent
  16. * @ORM\ManyToOne(targetEntity="BaseNode", inversedBy="children")
  17. * @ORM\JoinColumns({
  18. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
  19. * })
  20. */
  21. private $parent;
  22. /**
  23. * @ORM\OneToMany(targetEntity="BaseNode", mappedBy="parent")
  24. */
  25. private $children;
  26. /**
  27. * @Gedmo\Timestampable(on="create")
  28. * @ORM\Column(type="datetime")
  29. */
  30. private $created;
  31. /**
  32. * @ORM\Column(length=128, unique=true)
  33. */
  34. private $identifier;
  35. /**
  36. * @ORM\Column(type="datetime")
  37. * @Gedmo\Timestampable
  38. */
  39. private $updated;
  40. public function getCreated()
  41. {
  42. return $this->created;
  43. }
  44. public function getUpdated()
  45. {
  46. return $this->updated;
  47. }
  48. public function setParent($parent = null)
  49. {
  50. $this->parent = $parent;
  51. }
  52. public function getChildren()
  53. {
  54. return $this->children;
  55. }
  56. public function getParent()
  57. {
  58. return $this->parent;
  59. }
  60. public function getIdentifier()
  61. {
  62. return $this->identifier;
  63. }
  64. public function setIdentifier($identifier)
  65. {
  66. $this->identifier = $identifier;
  67. }
  68. }