@@ 11-72 (lines=62) @@ | ||
8 | /** |
|
9 | * @ODM\Document |
|
10 | */ |
|
11 | class Owner |
|
12 | { |
|
13 | ||
14 | /** |
|
15 | * @ODM\Id |
|
16 | */ |
|
17 | private $id; |
|
18 | ||
19 | /** |
|
20 | * @ODM\String |
|
21 | */ |
|
22 | private $name; |
|
23 | ||
24 | /** |
|
25 | * @ODM\ReferenceMany(targetDocument="Car") |
|
26 | * @var ArrayCollection |
|
27 | */ |
|
28 | private $owned_cars; |
|
29 | ||
30 | public function __construct($name = null, Car $car = null) |
|
31 | { |
|
32 | $this->owned_cars = new ArrayCollection(); |
|
33 | $this->name = $name; |
|
34 | if ($car) { |
|
35 | $this->owned_cars->add($car); |
|
36 | } |
|
37 | } |
|
38 | ||
39 | public function getId() |
|
40 | { |
|
41 | return $this->id; |
|
42 | } |
|
43 | ||
44 | public function setName($name) |
|
45 | { |
|
46 | $this->name = $name; |
|
47 | } |
|
48 | ||
49 | public function getName() |
|
50 | { |
|
51 | return $this->name; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * @param ArrayCollection $ownedCars |
|
56 | */ |
|
57 | public function setOwnedCars($ownedCars) |
|
58 | { |
|
59 | $this->owned_cars = new ArrayCollection(); |
|
60 | foreach ($ownedCars as $car) { |
|
61 | $this->owned_cars->add($car); |
|
62 | } |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * @return ArrayCollection |
|
67 | */ |
|
68 | public function getOwnedCars() |
|
69 | { |
|
70 | return $this->owned_cars; |
|
71 | } |
|
72 | } |
|
73 |
@@ 11-74 (lines=64) @@ | ||
8 | /** |
|
9 | * @ORM\Entity() |
|
10 | */ |
|
11 | class Owner |
|
12 | { |
|
13 | ||
14 | /** |
|
15 | * @ORM\Column(name="id", type="integer") |
|
16 | * @ORM\Id |
|
17 | * @ORM\GeneratedValue(strategy="AUTO") |
|
18 | */ |
|
19 | private $id; |
|
20 | ||
21 | /** |
|
22 | * @ORM\Column(type="string") |
|
23 | */ |
|
24 | private $name; |
|
25 | ||
26 | /** |
|
27 | * @ORM\OneToMany(targetEntity="Car", mappedBy="owner") |
|
28 | * @var ArrayCollection |
|
29 | */ |
|
30 | private $owned_cars; |
|
31 | ||
32 | public function __construct($name = null, Car $car = null) |
|
33 | { |
|
34 | $this->owned_cars = new ArrayCollection(); |
|
35 | $this->name = $name; |
|
36 | if ($car) { |
|
37 | $this->owned_cars->add($car); |
|
38 | } |
|
39 | } |
|
40 | ||
41 | public function getId() |
|
42 | { |
|
43 | return $this->id; |
|
44 | } |
|
45 | ||
46 | public function setName($name) |
|
47 | { |
|
48 | $this->name = $name; |
|
49 | } |
|
50 | ||
51 | public function getName() |
|
52 | { |
|
53 | return $this->name; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @param ArrayCollection $ownedCars |
|
58 | */ |
|
59 | public function setOwnedCars($ownedCars) |
|
60 | { |
|
61 | $this->owned_cars = new ArrayCollection(); |
|
62 | foreach ($ownedCars as $car) { |
|
63 | $this->owned_cars->add($car); |
|
64 | } |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @return ArrayCollection |
|
69 | */ |
|
70 | public function getOwnedCars() |
|
71 | { |
|
72 | return $this->owned_cars; |
|
73 | } |
|
74 | } |
|
75 |