1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2016 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\LeadBundle\Entity; |
||
13 | |||
14 | use Doctrine\ORM\Mapping as ORM; |
||
15 | use Mautic\ApiBundle\Serializer\Driver\ApiMetadataDriver; |
||
16 | use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; |
||
17 | |||
18 | /** |
||
19 | * Class DoNotContact. |
||
20 | */ |
||
21 | class DoNotContact |
||
22 | { |
||
23 | /** |
||
24 | * Lead is contactable. |
||
25 | */ |
||
26 | const IS_CONTACTABLE = 0; |
||
27 | |||
28 | /** |
||
29 | * Lead unsubscribed themselves. |
||
30 | */ |
||
31 | const UNSUBSCRIBED = 1; |
||
32 | |||
33 | /** |
||
34 | * Lead was unsubscribed due to an unsuccessful send. |
||
35 | */ |
||
36 | const BOUNCED = 2; |
||
37 | |||
38 | /** |
||
39 | * Lead was manually unsubscribed by user. |
||
40 | */ |
||
41 | const MANUAL = 3; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | private $id; |
||
47 | |||
48 | /** |
||
49 | * @var Lead |
||
50 | */ |
||
51 | private $lead; |
||
52 | |||
53 | /** |
||
54 | * @var \DateTime |
||
55 | */ |
||
56 | private $dateAdded; |
||
57 | |||
58 | /** |
||
59 | * @var int |
||
60 | */ |
||
61 | private $reason = 0; |
||
62 | |||
63 | /** |
||
64 | * @var string |
||
65 | */ |
||
66 | private $comments; |
||
67 | |||
68 | /** |
||
69 | * @var string |
||
70 | */ |
||
71 | private $channel; |
||
72 | |||
73 | private $channelId; |
||
74 | |||
75 | public static function loadMetadata(ORM\ClassMetadata $metadata) |
||
76 | { |
||
77 | $builder = new ClassMetadataBuilder($metadata); |
||
78 | |||
79 | $builder->setTable('lead_donotcontact') |
||
80 | ->setCustomRepositoryClass('Mautic\LeadBundle\Entity\DoNotContactRepository') |
||
81 | ->addIndex(['reason'], 'dnc_reason_search'); |
||
82 | |||
83 | $builder->addId(); |
||
84 | |||
85 | $builder->addLead(true, 'CASCADE', false, 'doNotContact'); |
||
0 ignored issues
–
show
|
|||
86 | |||
87 | $builder->addDateAdded(); |
||
88 | |||
89 | $builder->createField('reason', 'smallint') |
||
90 | ->build(); |
||
91 | |||
92 | $builder->createField('channel', 'string') |
||
93 | ->build(); |
||
94 | |||
95 | $builder->addNamedField('channelId', 'integer', 'channel_id', true); |
||
96 | |||
97 | $builder->createField('comments', 'text') |
||
98 | ->nullable() |
||
99 | ->build(); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Prepares the metadata for API usage. |
||
104 | * |
||
105 | * @param $metadata |
||
106 | */ |
||
107 | public static function loadApiMetadata(ApiMetadataDriver $metadata) |
||
108 | { |
||
109 | $metadata->setGroupPrefix('doNotContact') |
||
110 | ->addListProperties( |
||
111 | [ |
||
112 | 'id', |
||
113 | 'dateAdded', |
||
114 | 'reason', |
||
115 | 'comments', |
||
116 | 'channel', |
||
117 | 'channelId', |
||
118 | ] |
||
119 | ) |
||
120 | ->addProperties( |
||
121 | [ |
||
122 | 'lead', |
||
123 | ] |
||
124 | ) |
||
125 | ->build(); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * @return int |
||
130 | */ |
||
131 | public function getId() |
||
132 | { |
||
133 | return $this->id; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @return Lead |
||
138 | */ |
||
139 | public function getLead() |
||
140 | { |
||
141 | return $this->lead; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * @return DoNotContact |
||
146 | */ |
||
147 | public function setLead(Lead $lead) |
||
148 | { |
||
149 | $this->lead = $lead; |
||
150 | |||
151 | return $this; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @return \DateTime |
||
156 | */ |
||
157 | public function getDateAdded() |
||
158 | { |
||
159 | return $this->dateAdded; |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * @return DoNotContact |
||
164 | */ |
||
165 | public function setDateAdded(\DateTime $dateAdded) |
||
166 | { |
||
167 | $this->dateAdded = $dateAdded; |
||
168 | |||
169 | return $this; |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * @return int |
||
174 | */ |
||
175 | public function getReason() |
||
176 | { |
||
177 | return $this->reason; |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * @param int $reason |
||
182 | * |
||
183 | * @return DoNotContact |
||
184 | */ |
||
185 | public function setReason($reason) |
||
186 | { |
||
187 | $this->reason = $reason; |
||
188 | |||
189 | return $this; |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getComments() |
||
196 | { |
||
197 | return $this->comments; |
||
198 | } |
||
199 | |||
200 | /** |
||
201 | * @param string $comments |
||
202 | * |
||
203 | * @return DoNotContact |
||
204 | */ |
||
205 | public function setComments($comments) |
||
206 | { |
||
207 | $this->comments = $comments; |
||
208 | |||
209 | return $this; |
||
210 | } |
||
211 | |||
212 | /** |
||
213 | * @return string |
||
214 | */ |
||
215 | public function getChannel() |
||
216 | { |
||
217 | return $this->channel; |
||
218 | } |
||
219 | |||
220 | /** |
||
221 | * @param string $channel |
||
222 | * |
||
223 | * @return DoNotContact |
||
224 | */ |
||
225 | public function setChannel($channel) |
||
226 | { |
||
227 | $this->channel = $channel; |
||
228 | |||
229 | return $this; |
||
230 | } |
||
231 | |||
232 | /** |
||
233 | * @return mixed |
||
234 | */ |
||
235 | public function getChannelId() |
||
236 | { |
||
237 | return $this->channelId; |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * @param mixed $channelId |
||
242 | * |
||
243 | * @return DoNotContact |
||
244 | */ |
||
245 | public function setChannelId($channelId) |
||
246 | { |
||
247 | $this->channelId = $channelId; |
||
248 | |||
249 | return $this; |
||
250 | } |
||
251 | } |
||
252 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.