Guest User

Untitled

a guest
Jan 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. class Sport {
  2. /**
  3. * Bidirectional - Many facilies are related to one sport
  4. *
  5. * @ORMOneToMany(targetEntity="SportsFacility", mappedBy="sport")
  6. */
  7. protected $facilities;
  8. public function getFacilities() {
  9. return $this->facilities;
  10. }
  11.  
  12. public function setFacilities($facilities) {
  13. $this->facilities = $facilities;
  14. return $this;
  15. }
  16. }
  17.  
  18. class Facility {
  19. /**
  20. * Bidirectional - Many sports are related to one facility
  21. *
  22. * @ORMOneToMany(targetEntity="SportsFacility", mappedBy="facility")
  23. */
  24. protected $sports;
  25. public function getSports() {
  26. return $this->sports;
  27. }
  28.  
  29. public function setSports($sportsFacilities) {
  30. $this->sports = $sportsFacilities;
  31. return $this;
  32. }
  33.  
  34. public function addSports($sportsFacilities) {
  35. $this->sports = $sportsFacilities;
  36. return $this;
  37. }
  38. }
  39.  
  40. class SportsFacility {
  41. /**
  42. * @var integer $sportsFacilityId
  43. *
  44. * @ORMColumn(name="sportsFacilityId", type="integer", nullable=false)
  45. * @ORMId
  46. * @ORMGeneratedValue(strategy="AUTO")
  47. */
  48. protected $sportsFacilityId;
  49.  
  50. /**
  51. * Bidirectional - Many Sports are related to one Facility (OWNING SIDE)
  52. *
  53. * @ORMManyToOne(targetEntity="Sport", inversedBy="facilities"))
  54. * @ORMJoinColumn(name="sportId", referencedColumnName="sportId"))
  55.  
  56. */
  57. protected $sport;
  58. /**
  59. * Bidirectional - Many Facilities are related to one Sport (OWNING SIDE)
  60. *
  61. * @ORMManyToOne(targetEntity="Facility", inversedBy="sports"))
  62. * @ORMJoinColumn(name="facilityId", referencedColumnName="facilityId"))
  63. */
  64. protected $facility;
  65.  
  66. public function getSportsFacilityId() {
  67. return $this->sportsFacilityId;
  68. }
  69.  
  70. public function setSportsFacilityId($sportsFacilityId) {
  71. $this->sportsFacilityId = $sportsFacilityId;
  72. return $this;
  73. }
  74.  
  75. public function getSport() {
  76. return $this->sport;
  77. }
  78.  
  79. public function setSport($sport) {
  80. $this->sport = $sport;
  81. return $this;
  82. }
  83.  
  84. public function getFacility() {
  85. return $this->facility;
  86. }
  87.  
  88. public function setFacility($facility) {
  89. $this->facility = $facility;
  90. return $this;
  91. }
  92. }
  93.  
  94. protected function configureFormFields(FormMapper $formMapper)
  95. {
  96. $formMapper
  97. ->add('name')
  98. ->with('Sports')
  99. ->add('sports', 'sonata_type_collection',
  100. array('by_reference' => false),
  101. array(
  102. 'edit' => 'inline',
  103. 'inline' => 'table',
  104. ))
  105. ->end();
  106. }
Add Comment
Please, Sign In to add comment