Advertisement
NonaG

Blog-PHP/articles

Mar 14th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. <?php
  2.  
  3. namespace SoftUniBlogBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7. /**
  8. * Article
  9. *
  10. * @ORM\Table(name="articles")
  11. * @ORM\Entity(repositoryClass="SoftUniBlogBundle\Repository\ArticleRepository")
  12. */
  13. class Article
  14. {
  15. /**
  16. * @var int
  17. *
  18. * @ORM\Column(name="id", type="integer")
  19. * @ORM\Id
  20. * @ORM\GeneratedValue(strategy="AUTO")
  21. */
  22. private $id;
  23.  
  24. /**
  25. * @var string
  26. *
  27. * @ORM\Column(name="title", type="string", length=255)
  28. */
  29. private $title;
  30.  
  31. /**
  32. * @var string
  33. *
  34. * @ORM\Column(name="content", type="text")
  35. */
  36. private $content;
  37.  
  38. /**
  39. * @var \DateTime
  40. *
  41. * @ORM\Column(name="dateAdded", type="datetime")
  42. */
  43. private $dateAdded;
  44. /*
  45. * @var string
  46. */
  47. private $summary;
  48. /*
  49. * @var int
  50. *
  51. * @ORM\Column(name="authorID",type="integer")
  52. */
  53. private $authorId;
  54. /*
  55. * @var User
  56. *
  57. * @ORM\ManyToOne(targetEntity="SoftUniBlogBundle\Entity\User",inversedBy="articles")
  58. *@ORM\JoinColumn(name="authorId",referencedColumnName="id")
  59. */
  60. private $author;
  61. /*
  62. * @param \SoftUniBlogBundle\Entity\User $author
  63. *
  64. * @return Article
  65. */
  66. public function setAuthor(User $author=null)
  67. {
  68. $this->author=$author;
  69. return $this;
  70. }
  71. public function getAuthor()
  72. {
  73. return $this->author;
  74. }
  75. /*
  76. * @param integer $authorID
  77. *
  78. * @return Article
  79. */
  80. public function setAuthorID($authorID)
  81. {
  82. $this->authorId=$authorID;
  83. return $this;
  84. }
  85. /*
  86. * @return \SoftUniBundle\Entity\User
  87. */
  88. public function getAuthorId()
  89. {
  90. return $this->authorId;
  91. }
  92. /*
  93. * @param string
  94. */
  95. private function setSummary()
  96. {
  97. $this->summary=substr($this->getContent(),0,strlen($this->getContent())/2)."...";
  98. }
  99. /*
  100. * @return string
  101. */
  102. public function getSummary()
  103. {
  104. if ($this->summary===null)
  105. {
  106. $this->setSummary();
  107. }
  108. return $this->summary;
  109. }
  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 Article
  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 content
  147. *
  148. * @param string $content
  149. *
  150. * @return Article
  151. */
  152. public function setContent($content)
  153. {
  154. $this->content = $content;
  155.  
  156. return $this;
  157. }
  158.  
  159. /**
  160. * Get content
  161. *
  162. * @return string
  163. */
  164. public function getContent()
  165. {
  166. return $this->content;
  167. }
  168.  
  169. /**
  170. * Set dateAdded
  171. *
  172. * @param \DateTime $dateAdded
  173. *
  174. * @return Article
  175. */
  176. public function setDateAdded($dateAdded)
  177. {
  178. $this->dateAdded = $dateAdded;
  179.  
  180. return $this;
  181. }
  182.  
  183. /**
  184. * Get dateAdded
  185. *
  186. * @return \DateTime
  187. */
  188. public function getDateAdded()
  189. {
  190. return $this->dateAdded;
  191. }
  192. public function _construct()
  193. {
  194. $this->dateAdded=new \DateTime('now');
  195. }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement