LegacyUser.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Doctrine\Tests\Models\Legacy;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. /**
  5. * @Entity
  6. * @Table(name="legacy_users")
  7. */
  8. class LegacyUser
  9. {
  10. /**
  11. * @Id
  12. * @GeneratedValue
  13. * @Column(name="iUserId", type="integer", nullable=false)
  14. */
  15. public $_id;
  16. /**
  17. * @Column(name="sUsername", type="string", length=255, unique=true)
  18. */
  19. public $_username;
  20. /**
  21. * @Column(type="string", length=255)
  22. */
  23. public $_name;
  24. /**
  25. * @OneToMany(targetEntity="LegacyArticle", mappedBy="_user")
  26. */
  27. public $_articles;
  28. /**
  29. * @OneToMany(targetEntity="LegacyUserReference", mappedBy="_source", cascade={"remove"})
  30. */
  31. public $_references;
  32. /**
  33. * @ManyToMany(targetEntity="LegacyCar", inversedBy="_users", cascade={"persist", "merge"})
  34. * @JoinTable(name="legacy_users_cars",
  35. * joinColumns={@JoinColumn(name="iUserId", referencedColumnName="iUserId")},
  36. * inverseJoinColumns={@JoinColumn(name="iCarId", referencedColumnName="iCarId")}
  37. * )
  38. */
  39. public $_cars;
  40. public function __construct() {
  41. $this->_articles = new ArrayCollection;
  42. $this->_references = new ArrayCollection;
  43. $this->_cars = new ArrayCollection;
  44. }
  45. public function getId() {
  46. return $this->_id;
  47. }
  48. public function getUsername() {
  49. return $this->_username;
  50. }
  51. public function addArticle(LegacyArticle $article) {
  52. $this->_articles[] = $article;
  53. $article->setAuthor($this);
  54. }
  55. public function addReference($reference)
  56. {
  57. $this->_references[] = $reference;
  58. }
  59. public function references()
  60. {
  61. return $this->_references;
  62. }
  63. public function addCar(LegacyCar $car) {
  64. $this->_cars[] = $car;
  65. $car->addUser($this);
  66. }
  67. public function getCars() {
  68. return $this->_cars;
  69. }
  70. }