1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use AppBundle\Price\Price; |
6
|
|
|
use AppBundle\Util\Uuid; |
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
9
|
|
|
use Doctrine\ORM\Mapping\Id; |
10
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
11
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
12
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
13
|
|
|
use Symfony\Component\Validator\Constraints\Range; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @Entity(repositoryClass="MealRepository") |
17
|
|
|
*/ |
18
|
|
|
class Meal |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @Id |
22
|
|
|
* @Column(type="string", length=40) |
23
|
|
|
*/ |
24
|
|
|
private $id; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @ManyToOne(targetEntity="Category", inversedBy="meals") |
28
|
|
|
* @JoinColumn(nullable=false, onDelete="CASCADE") |
29
|
|
|
*/ |
30
|
|
|
private $category; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @Column(type="string", length=128) |
34
|
|
|
* @NotBlank |
35
|
|
|
*/ |
36
|
|
|
private $name; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @Column(type="text", nullable=true) |
40
|
|
|
*/ |
41
|
|
|
private $description; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @Column(type="string", length=10) |
45
|
|
|
* @Range(min=1, minMessage="Le prix n'est pas correct, maman") |
46
|
|
|
*/ |
47
|
|
|
private $price = '0'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @Column(type="integer") |
51
|
|
|
*/ |
52
|
|
|
private $position = 1; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @Column(type="boolean") |
56
|
|
|
*/ |
57
|
|
|
private $active = true; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @Column(type="boolean") |
61
|
|
|
*/ |
62
|
|
|
private $portuguese = false; |
63
|
|
|
|
64
|
|
|
public function __construct() |
65
|
|
|
{ |
66
|
|
|
$this->id = Uuid::generateV4(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getId() |
70
|
|
|
{ |
71
|
|
|
return $this->id; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getName() |
75
|
|
|
{ |
76
|
|
|
return $this->name; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function setName($name) |
80
|
|
|
{ |
81
|
|
|
$this->name = $name; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getCategory() |
87
|
|
|
{ |
88
|
|
|
return $this->category; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function setCategory(Category $category) |
92
|
|
|
{ |
93
|
|
|
$this->category = $category; |
94
|
|
|
|
95
|
|
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function getDescription() |
99
|
|
|
{ |
100
|
|
|
return $this->description; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function setDescription($description) |
104
|
|
|
{ |
105
|
|
|
$this->description = $description; |
106
|
|
|
|
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getPosition() |
111
|
|
|
{ |
112
|
|
|
return $this->position; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function setPosition($position) |
116
|
|
|
{ |
117
|
|
|
$this->position = $position; |
118
|
|
|
|
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getPrice() |
123
|
|
|
{ |
124
|
|
|
return new Price($this->price); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function setPrice(Price $price) |
128
|
|
|
{ |
129
|
|
|
$this->price = $price->getAmount(); |
130
|
|
|
|
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function isActive() |
135
|
|
|
{ |
136
|
|
|
return $this->active; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function setActive($active = true) |
140
|
|
|
{ |
141
|
|
|
$this->active = $active; |
142
|
|
|
|
143
|
|
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function isPortuguese() |
147
|
|
|
{ |
148
|
|
|
return $this->portuguese; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function setPortuguese($portuguese = true) |
152
|
|
|
{ |
153
|
|
|
$this->portuguese = $portuguese; |
154
|
|
|
|
155
|
|
|
return $this; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|