DDC117Article.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace Doctrine\Tests\Models\DDC117;
  3. /**
  4. * @Entity
  5. */
  6. class DDC117Article
  7. {
  8. /** @Id @Column(type="integer", name="article_id") @GeneratedValue */
  9. private $id;
  10. /** @Column */
  11. private $title;
  12. /**
  13. * @OneToMany(targetEntity="DDC117Reference", mappedBy="source", cascade={"remove"})
  14. */
  15. private $references;
  16. /**
  17. * @OneToOne(targetEntity="DDC117ArticleDetails", mappedBy="article", cascade={"persist", "remove"})
  18. */
  19. private $details;
  20. /**
  21. * @OneToMany(targetEntity="DDC117Translation", mappedBy="article", cascade={"persist", "remove"})
  22. */
  23. private $translations;
  24. /**
  25. * @OneToMany(targetEntity="DDC117Link", mappedBy="source")
  26. */
  27. private $links;
  28. public function __construct($title)
  29. {
  30. $this->title = $title;
  31. $this->references = new \Doctrine\Common\Collections\ArrayCollection();
  32. $this->translations = new \Doctrine\Common\Collections\ArrayCollection();
  33. }
  34. public function setDetails($details)
  35. {
  36. $this->details = $details;
  37. }
  38. public function id()
  39. {
  40. return $this->id;
  41. }
  42. public function addReference($reference)
  43. {
  44. $this->references[] = $reference;
  45. }
  46. public function references()
  47. {
  48. return $this->references;
  49. }
  50. public function addTranslation($language, $title)
  51. {
  52. $this->translations[] = new DDC117Translation($this, $language, $title);
  53. }
  54. public function getText()
  55. {
  56. return $this->details->getText();
  57. }
  58. public function getDetails()
  59. {
  60. return $this->details;
  61. }
  62. public function resetText()
  63. {
  64. $this->details = null;
  65. }
  66. public function getTranslations()
  67. {
  68. return $this->translations;
  69. }
  70. }