|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Donut Social Network - Yet another experimental social network. |
|
5
|
|
|
* Copyright (C) 2016-2017, Dejan Angelov <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This file is part of Donut Social Network. |
|
8
|
|
|
* |
|
9
|
|
|
* Donut Social Network is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU General Public License as published by |
|
11
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
12
|
|
|
* (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* Donut Social Network is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with Donut Social Network. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
* @package Donut Social Network |
|
23
|
|
|
* @copyright Copyright (C) 2016-2017, Dejan Angelov <[email protected]> |
|
24
|
|
|
* @license https://github.com/angelov/donut/blob/master/LICENSE |
|
25
|
|
|
* @author Dejan Angelov <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
namespace Angelov\Donut\Movies; |
|
29
|
|
|
|
|
30
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
31
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @ORM\Entity |
|
35
|
|
|
* @ORM\Table(name="movie") |
|
36
|
|
|
*/ |
|
37
|
|
|
class Movie |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* @ORM\Id |
|
41
|
|
|
* @ORM\GeneratedValue(strategy="NONE") |
|
42
|
|
|
* @ORM\Column(type="guid") |
|
43
|
|
|
*/ |
|
44
|
|
|
private $id; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @ORM\Column(type="string") |
|
48
|
|
|
*/ |
|
49
|
|
|
private $title; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @ORM\Column(type="integer") |
|
53
|
|
|
*/ |
|
54
|
|
|
private $year; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @ORM\Column(type="string") |
|
58
|
|
|
*/ |
|
59
|
|
|
private $plot; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @ORM\ManyToMany(targetEntity="Angelov\Donut\Movies\Genre", inversedBy="movies") |
|
63
|
|
|
* @ORM\JoinTable( |
|
64
|
|
|
* name="movie_has_genre", |
|
65
|
|
|
* joinColumns={ |
|
66
|
|
|
* @ORM\JoinColumn(name="movie_id", referencedColumnName="id") |
|
67
|
|
|
* }, |
|
68
|
|
|
* inverseJoinColumns={ |
|
69
|
|
|
* @ORM\JoinColumn(name="genre_id", referencedColumnName="id") |
|
70
|
|
|
* } |
|
71
|
|
|
* ) |
|
72
|
|
|
*/ |
|
73
|
|
|
private $genres; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @ORM\Column(type="string") |
|
77
|
|
|
*/ |
|
78
|
|
|
private $poster = ''; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param $genres Genre[] |
|
82
|
|
|
*/ |
|
83
|
|
|
public function __construct(string $id, string $title, int $year, string $plot = '', array $genres = []) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->id = $id; |
|
86
|
|
|
$this->title = $title; |
|
87
|
|
|
$this->year = $year; |
|
88
|
|
|
$this->plot = $plot; |
|
89
|
|
|
$this->genres = new ArrayCollection($genres); |
|
90
|
|
|
|
|
91
|
|
|
foreach ($genres as $genre) { |
|
92
|
|
|
$genre->addMovie($this); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getId() : string |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->id; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function setId(string $id) : void |
|
102
|
|
|
{ |
|
103
|
|
|
$this->id = $id; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function getTitle() : string |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->title; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
public function setTitle(string $title) : void |
|
112
|
|
|
{ |
|
113
|
|
|
$this->title = $title; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function getYear() : int |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->year; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function setYear(int $year) : void |
|
122
|
|
|
{ |
|
123
|
|
|
$this->year = $year; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function getPlot() : string |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->plot; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function setPlot(string $plot) : void |
|
132
|
|
|
{ |
|
133
|
|
|
$this->plot = $plot; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function getGenres() : array |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->genres->getValues(); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function addGenre(Genre $genre) : void |
|
142
|
|
|
{ |
|
143
|
|
|
if (!$this->genres->contains($genre)) { |
|
144
|
|
|
$this->genres->add($genre); |
|
145
|
|
|
$genre->addMovie($this); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function getPoster() : string |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->poster; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function setPoster(string $poster) : void |
|
155
|
|
|
{ |
|
156
|
|
|
$this->poster = $poster; |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|