Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. <?php
  2.  
  3. namespace BaseBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8.  
  9. /**
  10. * BaseCategory
  11. *
  12. * @ORM\Entity()
  13. * @ORM\InheritanceType("JOINED")
  14. * @ORM\DiscriminatorColumn(name="type", type="string")
  15. * @ORM\DiscriminatorMap({
  16. * "article_category" = "AppBundle\Entity\ArticleCategory",
  17. * "page_category" = "AppBundle\Entity\PageCategory",
  18. * })
  19. * @Gedmo\Tree(type="nested")
  20. */
  21. abstract class BaseCategory
  22. {
  23. use \BaseBundle\Traits\SeoTrait;
  24.  
  25. /**
  26. * @var int
  27. *
  28. * @ORM\Column(name="id", type="integer")
  29. * @ORM\Id
  30. * @ORM\GeneratedValue(strategy="AUTO")
  31. */
  32. private $id;
  33.  
  34. /**
  35. * @var string
  36. *
  37. * @ORM\Column(name="title", type="string", length=255)
  38. * @Assert\NotBlank()
  39. */
  40. private $title;
  41.  
  42. /**
  43. * @var string
  44. *
  45. * @ORM\Column(name="slug", type="string", length=255, unique=true)
  46. * @Gedmo\Slug(fields={"title"})
  47. */
  48. private $slug;
  49.  
  50. /**
  51. * @var string
  52. *
  53. * @ORM\Column(name="description", type="text")
  54. */
  55. private $description;
  56.  
  57. /**
  58. * @var \DateTime
  59. *
  60. * @ORM\Column(type="datetime")
  61. * @Gedmo\Timestampable(on="create")
  62. */
  63. private $createdAt;
  64.  
  65. /**
  66. * @var \DateTime
  67. *
  68. * @ORM\Column(type="datetime")
  69. * @Gedmo\Timestampable(on="update")
  70. */
  71. private $updatedAt;
  72.  
  73. /**
  74. * @Gedmo\TreeLeft
  75. * @ORM\Column(type="integer")
  76. */
  77. private $lft;
  78.  
  79. /**
  80. * @Gedmo\TreeLevel
  81. * @ORM\Column(type="integer")
  82. */
  83. private $lvl;
  84.  
  85. /**
  86. * @Gedmo\TreeRight
  87. * @ORM\Column(type="integer")
  88. */
  89. private $rgt;
  90.  
  91. /**
  92. * @Gedmo\TreeRoot
  93. * @ORM\ManyToOne(targetEntity="BaseCategory")
  94. * @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
  95. */
  96. private $root;
  97.  
  98. /**
  99. * @Gedmo\TreeParent
  100. * @ORM\ManyToOne(targetEntity="BaseCategory", inversedBy="children")
  101. * @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
  102. */
  103. private $parent;
  104.  
  105. /**
  106. * @ORM\OneToMany(targetEntity="BaseCategory", mappedBy="parent")
  107. * @ORM\OrderBy({"lft" = "ASC"})
  108. */
  109. private $children;
  110.  
  111. /**
  112. * Get id
  113. *
  114. * @return int
  115. */
  116. public function getId()
  117. {
  118. return $this->id;
  119. }
  120.  
  121. /**
  122. * Set title
  123. *
  124. * @param string $title
  125. *
  126. * @return BaseCategory
  127. */
  128. public function setTitle($title)
  129. {
  130. $this->title = $title;
  131.  
  132. return $this;
  133. }
  134.  
  135. /**
  136. * Get title
  137. *
  138. * @return string
  139. */
  140. public function getTitle()
  141. {
  142. return $this->title;
  143. }
  144.  
  145. /**
  146. * Set slug
  147. *
  148. * @param string $slug
  149. *
  150. * @return BaseCategory
  151. */
  152. public function setSlug($slug)
  153. {
  154. $this->slug = $slug;
  155.  
  156. return $this;
  157. }
  158.  
  159. /**
  160. * Get slug
  161. *
  162. * @return string
  163. */
  164. public function getSlug()
  165. {
  166. return $this->slug;
  167. }
  168.  
  169. /**
  170. * Set description
  171. *
  172. * @param string $description
  173. *
  174. * @return BaseCategory
  175. */
  176. public function setDescription($description)
  177. {
  178. $this->description = $description;
  179.  
  180. return $this;
  181. }
  182.  
  183. /**
  184. * Get description
  185. *
  186. * @return string
  187. */
  188. public function getDescription()
  189. {
  190. return $this->description;
  191. }
  192.  
  193. /**
  194. * @return \DateTime
  195. */
  196. public function getCreatedAt()
  197. {
  198. return $this->createdAt;
  199. }
  200.  
  201. /**
  202. * @return \DateTime
  203. */
  204. public function getUpdatedAt()
  205. {
  206. return $this->updatedAt;
  207. }
  208.  
  209. public function getRoot()
  210. {
  211. return $this->root;
  212. }
  213.  
  214. public function setParent(BaseCategory $parent = null)
  215. {
  216. $this->parent = $parent;
  217. }
  218.  
  219. public function getParent()
  220. {
  221. return $this->parent;
  222. }
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement