1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Starkerxp\CampaignBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Starkerxp\StructureBundle\Entity\UserEntity; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Campaign. |
10
|
|
|
* |
11
|
|
|
* @ORM\Table(name="campaign", indexes={ |
12
|
|
|
* @ORM\Index(columns={"created_at"}), |
13
|
|
|
* @ORM\Index(columns={"updated_at"}), |
14
|
|
|
* @ORM\Index(columns={"name"}), |
15
|
|
|
* @ORM\Index(columns={"deleted"}), |
16
|
|
|
* @ORM\Index(columns={"status"}) |
17
|
|
|
* }) |
18
|
|
|
* @ORM\Entity(repositoryClass="Starkerxp\CampaignBundle\Repository\CampaignRepository") |
19
|
|
|
*/ |
20
|
|
|
class Campaign extends UserEntity |
21
|
|
|
{ |
22
|
|
|
const DRAFT = 'draft'; |
23
|
|
|
const PENDING = 'pending'; |
24
|
|
|
const SENT = 'send'; |
25
|
|
|
const CANCEL = 'cancel'; |
26
|
|
|
const ERROR = 'error'; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
* |
32
|
|
|
* @ORM\Column(name="name", type="string", length=255) |
33
|
|
|
*/ |
34
|
|
|
protected $name; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var bool |
38
|
|
|
* |
39
|
|
|
* @ORM\Column(name="deleted", type="boolean", options={"default": false}) |
40
|
|
|
*/ |
41
|
|
|
protected $deleted; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var string |
45
|
|
|
* |
46
|
|
|
* @ORM\Column(name="status", type="string", length=255) |
47
|
|
|
*/ |
48
|
|
|
protected $status; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var \DateTime |
52
|
|
|
* |
53
|
|
|
* @ORM\Column(name="date_start", type="datetime", nullable=true) |
54
|
|
|
*/ |
55
|
|
|
protected $dateStart; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @ORM\OneToMany( |
59
|
|
|
* targetEntity="Event", |
60
|
|
|
* mappedBy="campaign" |
61
|
|
|
* ) |
62
|
|
|
*/ |
63
|
|
|
protected $events; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @ORM\OneToMany( |
67
|
|
|
* targetEntity="CampaignTarget", |
68
|
|
|
* mappedBy="campaign" |
69
|
|
|
* ) |
70
|
|
|
*/ |
71
|
|
|
protected $targets; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Constructor |
75
|
|
|
*/ |
76
|
|
|
public function __construct() |
77
|
|
|
{ |
78
|
|
|
$this->events = new \Doctrine\Common\Collections\ArrayCollection(); |
79
|
|
|
$this->targets = new \Doctrine\Common\Collections\ArrayCollection(); |
80
|
|
|
$this->status = self::DRAFT; |
81
|
|
|
$this->deleted = false; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get name. |
86
|
|
|
* |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getName() |
90
|
|
|
{ |
91
|
|
|
return $this->name; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Set name. |
96
|
|
|
* |
97
|
|
|
* @param string $name |
98
|
|
|
* |
99
|
|
|
*/ |
100
|
|
|
public function setName($name) |
101
|
|
|
{ |
102
|
|
|
$this->name = $name; |
103
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Get status. |
108
|
|
|
* |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getStatus() |
112
|
|
|
{ |
113
|
|
|
return $this->status; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Set status. |
118
|
|
|
* |
119
|
|
|
* @param string $status |
120
|
|
|
* |
121
|
|
|
*/ |
122
|
|
|
public function setStatus($status) |
123
|
|
|
{ |
124
|
|
|
$this->status = $status; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Get deleted. |
129
|
|
|
* |
130
|
|
|
* @return bool |
131
|
|
|
*/ |
132
|
|
|
public function getDeleted() |
133
|
|
|
{ |
134
|
|
|
return $this->deleted; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Set deleted. |
139
|
|
|
* |
140
|
|
|
* @param bool $deleted |
141
|
|
|
* |
142
|
|
|
*/ |
143
|
|
|
public function setDeleted($deleted) |
144
|
|
|
{ |
145
|
|
|
$this->deleted = $deleted; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Add event |
150
|
|
|
* |
151
|
|
|
* @param \Starkerxp\CampaignBundle\Entity\Event $event |
152
|
|
|
* |
153
|
|
|
* @return Campaign |
154
|
|
|
*/ |
155
|
|
|
public function addEvent(\Starkerxp\CampaignBundle\Entity\Event $event) |
156
|
|
|
{ |
157
|
|
|
$this->events[] = $event; |
158
|
|
|
|
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Remove event |
164
|
|
|
* |
165
|
|
|
* @param \Starkerxp\CampaignBundle\Entity\Event $event |
166
|
|
|
*/ |
167
|
|
|
public function removeEvent(\Starkerxp\CampaignBundle\Entity\Event $event) |
168
|
|
|
{ |
169
|
|
|
$this->events->removeElement($event); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Get events |
174
|
|
|
* |
175
|
|
|
* @return \Doctrine\Common\Collections\Collection |
176
|
|
|
*/ |
177
|
|
|
public function getEvents() |
178
|
|
|
{ |
179
|
|
|
return $this->events; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Add target |
184
|
|
|
* |
185
|
|
|
* @param \Starkerxp\CampaignBundle\Entity\CampaignTarget $target |
186
|
|
|
* |
187
|
|
|
* @return Campaign |
188
|
|
|
*/ |
189
|
|
|
public function addTarget(\Starkerxp\CampaignBundle\Entity\CampaignTarget $target) |
190
|
|
|
{ |
191
|
|
|
$this->targets[] = $target; |
192
|
|
|
|
193
|
|
|
return $this; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Remove target |
198
|
|
|
* |
199
|
|
|
* @param \Starkerxp\CampaignBundle\Entity\CampaignTarget $target |
200
|
|
|
*/ |
201
|
|
|
public function removeTarget(\Starkerxp\CampaignBundle\Entity\CampaignTarget $target) |
202
|
|
|
{ |
203
|
|
|
$this->targets->removeElement($target); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* Get targets |
208
|
|
|
* |
209
|
|
|
* @return \Doctrine\Common\Collections\Collection |
210
|
|
|
*/ |
211
|
|
|
public function getTargets() |
212
|
|
|
{ |
213
|
|
|
return $this->targets; |
214
|
|
|
} |
215
|
|
|
} |
|
|
|
|
216
|
|
|
|
This check marks files that end in a newline character, i.e. an empy line.