|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* AnimeDb package. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Peter Gribanov <[email protected]> |
|
6
|
|
|
* @copyright Copyright (c) 2011, Peter Gribanov |
|
7
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 GPL v3 |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace AnimeDb\Bundle\CatalogBundle\Entity\Widget; |
|
11
|
|
|
|
|
12
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
13
|
|
|
use AnimeDb\Bundle\CatalogBundle\Entity\Item as ItemEntity; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Widget item. |
|
17
|
|
|
* |
|
18
|
|
|
* @author Peter Gribanov <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class Item |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $cover = ''; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $name = ''; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Link to a item in an external catalog. |
|
34
|
|
|
* |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $link = ''; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $link_for_fill = ''; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Item in local catalog if have. |
|
46
|
|
|
* |
|
47
|
|
|
* @return Item|null |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $item; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Type |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $type; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var ArrayCollection |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $genres; |
|
60
|
|
|
|
|
61
|
89 |
|
public function __construct() |
|
62
|
|
|
{ |
|
63
|
89 |
|
$this->genres = new ArrayCollection(); |
|
64
|
89 |
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param string $cover |
|
68
|
|
|
* |
|
69
|
|
|
* @return Item |
|
70
|
|
|
*/ |
|
71
|
1 |
|
public function setCover($cover) |
|
72
|
|
|
{ |
|
73
|
1 |
|
$this->cover = $cover; |
|
74
|
|
|
|
|
75
|
1 |
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
1 |
|
public function getCover() |
|
82
|
|
|
{ |
|
83
|
1 |
|
return $this->cover; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param string $name |
|
88
|
|
|
* |
|
89
|
|
|
* @return Item |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function setName($name) |
|
92
|
|
|
{ |
|
93
|
1 |
|
$this->name = $name; |
|
94
|
|
|
|
|
95
|
1 |
|
return $this; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return string |
|
100
|
|
|
*/ |
|
101
|
1 |
|
public function getName() |
|
102
|
|
|
{ |
|
103
|
1 |
|
return $this->name; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param string $link |
|
108
|
|
|
* |
|
109
|
|
|
* @return Item |
|
110
|
|
|
*/ |
|
111
|
1 |
|
public function setLink($link) |
|
112
|
|
|
{ |
|
113
|
1 |
|
$this->link = $link; |
|
114
|
|
|
|
|
115
|
1 |
|
return $this; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return string |
|
120
|
|
|
*/ |
|
121
|
1 |
|
public function getLink() |
|
122
|
|
|
{ |
|
123
|
1 |
|
return $this->link; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @param string $link |
|
128
|
|
|
* |
|
129
|
|
|
* @return Item |
|
130
|
|
|
*/ |
|
131
|
1 |
|
public function setLinkForFill($link) |
|
132
|
|
|
{ |
|
133
|
1 |
|
$this->link_for_fill = $link; |
|
134
|
|
|
|
|
135
|
1 |
|
return $this; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @return string |
|
140
|
|
|
*/ |
|
141
|
1 |
|
public function getLinkForFill() |
|
142
|
|
|
{ |
|
143
|
1 |
|
return $this->link_for_fill; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @param ItemEntity|null $item |
|
148
|
|
|
* |
|
149
|
|
|
* @return Item |
|
150
|
|
|
*/ |
|
151
|
2 |
|
public function setItem(ItemEntity $item = null) |
|
152
|
|
|
{ |
|
153
|
2 |
|
$this->item = $item; |
|
154
|
|
|
|
|
155
|
2 |
|
return $this; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Get item. |
|
160
|
|
|
* |
|
161
|
|
|
* @return ItemEntity|null |
|
162
|
|
|
*/ |
|
163
|
2 |
|
public function getItem() |
|
164
|
|
|
{ |
|
165
|
2 |
|
return $this->item; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Set type. |
|
170
|
|
|
* |
|
171
|
|
|
* @param Type $type |
|
172
|
|
|
* |
|
173
|
|
|
* @return Item |
|
174
|
|
|
*/ |
|
175
|
1 |
|
public function setType(Type $type) |
|
176
|
|
|
{ |
|
177
|
1 |
|
if ($this->type !== $type) { |
|
178
|
1 |
|
$this->type = $type; |
|
179
|
1 |
|
$type->setItem($this); |
|
180
|
1 |
|
} |
|
181
|
|
|
|
|
182
|
1 |
|
return $this; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @return Type |
|
187
|
|
|
*/ |
|
188
|
1 |
|
public function getType() |
|
189
|
|
|
{ |
|
190
|
1 |
|
return $this->type; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @param Genre $genre |
|
195
|
|
|
* |
|
196
|
|
|
* @return Item |
|
197
|
|
|
*/ |
|
198
|
1 |
|
public function addGenre(Genre $genre) |
|
199
|
|
|
{ |
|
200
|
1 |
|
if (!$this->genres->contains($genre)) { |
|
201
|
1 |
|
$this->genres->add($genre); |
|
202
|
1 |
|
$genre->setItem($this); |
|
203
|
1 |
|
} |
|
204
|
|
|
|
|
205
|
1 |
|
return $this; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* @return ArrayCollection |
|
210
|
|
|
*/ |
|
211
|
1 |
|
public function getGenres() |
|
212
|
|
|
{ |
|
213
|
1 |
|
return $this->genres; |
|
214
|
|
|
} |
|
215
|
|
|
} |
|
216
|
|
|
|