CmsArticle.php 938B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Doctrine\Tests\Models\CMS;
  3. /**
  4. * @Entity
  5. * @Table(name="cms_articles")
  6. */
  7. class CmsArticle
  8. {
  9. /**
  10. * @Id
  11. * @Column(type="integer")
  12. * @GeneratedValue(strategy="AUTO")
  13. */
  14. public $id;
  15. /**
  16. * @Column(type="string", length=255)
  17. */
  18. public $topic;
  19. /**
  20. * @Column(type="text")
  21. */
  22. public $text;
  23. /**
  24. * @ManyToOne(targetEntity="CmsUser", inversedBy="articles")
  25. * @JoinColumn(name="user_id", referencedColumnName="id")
  26. */
  27. public $user;
  28. /**
  29. * @OneToMany(targetEntity="CmsComment", mappedBy="article")
  30. */
  31. public $comments;
  32. /**
  33. * @Version @column(type="integer")
  34. */
  35. public $version;
  36. public function setAuthor(CmsUser $author) {
  37. $this->user = $author;
  38. }
  39. public function addComment(CmsComment $comment) {
  40. $this->comments[] = $comment;
  41. $comment->setArticle($this);
  42. }
  43. }