|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Presenters; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\MeetingModel; |
|
6
|
|
|
use App\Models\VisitorModel; |
|
7
|
|
|
use App\Models\BlockModel; |
|
8
|
|
|
use App\Models\MealModel; |
|
9
|
|
|
use App\Services\Emailer; |
|
10
|
|
|
use App\Services\VisitorService; |
|
11
|
|
|
use Nette\Http\Request; |
|
12
|
|
|
use Nette\Utils\Strings; |
|
13
|
|
|
use Tracy\Debugger; |
|
14
|
|
|
use Exception; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Visitor controller |
|
18
|
|
|
* |
|
19
|
|
|
* This file handles the retrieval and serving of visitors |
|
20
|
|
|
* |
|
21
|
|
|
* @author Tomas Litera |
|
22
|
|
|
* @copyright 2013-06-12 <[email protected]> |
|
23
|
|
|
* @package srazvs |
|
24
|
|
|
*/ |
|
25
|
|
|
class VisitorPresenter extends BasePresenter |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
const TEMPLATE_DIR = __DIR__ . '/../templates/visitor/'; |
|
29
|
|
|
const TEMPLATE_EXT = 'latte'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var Emailer |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $emailer; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var MealModel |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $mealModel; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var BlockModel |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $blockModel; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var MeetingModel |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $meetingModel; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var VisitorSErvice |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $visitorService; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param VisitorModel $visitors |
|
58
|
|
|
* @param MealModel $meals |
|
59
|
|
|
* @param BlockModel $blocks |
|
60
|
|
|
* @param MeetingModel $meetings |
|
61
|
|
|
* @param Emailer $emailer |
|
62
|
|
|
* @param Request $request |
|
63
|
|
|
*/ |
|
64
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
|
|
65
|
|
|
VisitorModel $visitors, |
|
66
|
|
|
MealModel $meals, |
|
67
|
|
|
BlockModel $blocks, |
|
68
|
|
|
MeetingModel $meetings, |
|
69
|
|
|
Emailer $emailer, |
|
70
|
|
|
VisitorService $visitor, |
|
71
|
|
|
Request $request |
|
72
|
|
|
) { |
|
73
|
|
|
$this->setModel($visitors); |
|
|
|
|
|
|
74
|
|
|
$this->setMealModel($meals); |
|
75
|
|
|
$this->setBlockModel($blocks); |
|
76
|
|
|
$this->setMeetingModel($meetings); |
|
77
|
|
|
$this->setEmailer($emailer); |
|
78
|
|
|
$this->setVisitorService($visitor); |
|
79
|
|
|
$this->setRequest($request); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return void |
|
84
|
|
|
*/ |
|
85
|
|
|
public function startup() |
|
86
|
|
|
{ |
|
87
|
|
|
parent::startup(); |
|
88
|
|
|
|
|
89
|
|
|
$this->getMeetingModel()->setMeetingId($this->getMeetingId()); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Process data from form |
|
94
|
|
|
* |
|
95
|
|
|
* @return void |
|
96
|
|
|
*/ |
|
97
|
|
View Code Duplication |
public function actionCreate() |
|
|
|
|
|
|
98
|
|
|
{ |
|
99
|
|
|
try { |
|
100
|
|
|
$postData = $this->getRequest()->getPost(); |
|
101
|
|
|
$postData['meeting'] = $this->getMeetingId(); |
|
102
|
|
|
|
|
103
|
|
|
$guid = $this->getVisitorService()->create($postData); |
|
104
|
|
|
$result = $this->sendRegistrationSummary($postData, $guid); |
|
105
|
|
|
|
|
106
|
|
|
Debugger::log('Creation of visitor('. $guid .') successfull, result: ' . json_encode($result), Debugger::INFO); |
|
107
|
|
|
$this->flashMessage('Účastník(' . $guid . ') byl úspěšně upraven.', 'ok'); |
|
108
|
|
|
} catch(Exception $e) { |
|
109
|
|
|
Debugger::log('Creation of visitor('. $guid .') failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
|
|
|
|
|
110
|
|
|
$this->flashMessage('Creation of visitor failed, result: ' . $e->getMessage(), 'error'); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
$this->redirect('Visitor:listing'); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Process data from editing |
|
118
|
|
|
* |
|
119
|
|
|
* @param integer $id |
|
120
|
|
|
* @return void |
|
121
|
|
|
*/ |
|
122
|
|
View Code Duplication |
public function actionUpdate($id) |
|
|
|
|
|
|
123
|
|
|
{ |
|
124
|
|
|
try { |
|
125
|
|
|
$postData = $this->getRequest()->getPost(); |
|
126
|
|
|
$postData['meeting'] = $this->getMeetingId(); |
|
127
|
|
|
$postData['visitor'] = $id; |
|
128
|
|
|
|
|
129
|
|
|
$result = $this->getVisitorService()->update($id, $postData); |
|
130
|
|
|
|
|
131
|
|
|
//$result = $this->sendRegistrationSummary($visitor, $guid); |
|
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
Debugger::log('Modification of visitor('. $id .') successfull, result: ' . json_encode($result), Debugger::INFO); |
|
134
|
|
|
$this->flashMessage('Účastník(' . $id . ') byl úspěšně upraven.', 'ok'); |
|
135
|
|
|
} catch(Exception $e) { |
|
136
|
|
|
Debugger::log('Modification of visitor('. $id .') failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
137
|
|
|
$this->flashMessage('Modification of visitor failed, result: ' . $e->getMessage(), 'error'); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
$this->redirect('Visitor:listing'); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @param int $id |
|
145
|
|
|
* @return void |
|
146
|
|
|
*/ |
|
147
|
|
View Code Duplication |
public function actionDelete($id) |
|
|
|
|
|
|
148
|
|
|
{ |
|
149
|
|
|
try { |
|
150
|
|
|
$result = $this->getVisitorService()->delete($id); |
|
151
|
|
|
|
|
152
|
|
|
Debugger::log('Destroying of visitor('. $id .') successfull, result: ' . json_encode($result), Debugger::INFO); |
|
153
|
|
|
$this->flashMessage('Položka byla úspěšně smazána', 'ok'); |
|
154
|
|
|
} catch(Exception $e) { |
|
155
|
|
|
Debugger::log('Destroying of visitor('. $id .') failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
156
|
|
|
$this->flashMessage('Destroying of visitor failed, result: ' . $e->getMessage(), 'error'); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
$this->redirect('Visitor:listing'); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Prepare mass mail form |
|
164
|
|
|
* |
|
165
|
|
|
* @return void |
|
166
|
|
|
*/ |
|
167
|
|
|
public function actionSend() |
|
168
|
|
|
{ |
|
169
|
|
|
try { |
|
170
|
|
|
$request = $this->getRequest(); |
|
171
|
|
|
$subject = $request->getPost('subject', ''); |
|
172
|
|
|
$message = $request->getPost('message', ''); |
|
173
|
|
|
$bcc = explode(',', preg_replace("/\s+/", "", $request->getPost('recipients', ''))); |
|
|
|
|
|
|
174
|
|
|
// fill bcc name and address |
|
175
|
|
|
$bcc = array_combine($bcc, $bcc); |
|
176
|
|
|
|
|
177
|
|
|
$mailParameters = $this->getContainer()->parameters['mail']; |
|
178
|
|
|
$recipient = [ |
|
179
|
|
|
$mailParameters['senderAddress'] => $mailParameters['senderName'], |
|
180
|
|
|
]; |
|
181
|
|
|
|
|
182
|
|
|
$template = $this->createMailTemplate(); |
|
183
|
|
|
$template->subject = $subject; |
|
|
|
|
|
|
184
|
|
|
$template->message = $message; |
|
|
|
|
|
|
185
|
|
|
|
|
186
|
|
|
$result = $this->getEmailer()->sendMail($recipient, $subject, (string) $template, $bcc); |
|
187
|
|
|
|
|
188
|
|
|
Debugger::log('E-mail was send successfully, result: ' . json_encode($result), Debugger::INFO); |
|
189
|
|
|
$this->flashMessage('E-mail byl úspěšně odeslán', 'ok'); |
|
190
|
|
|
} catch(Exception $e) { |
|
191
|
|
|
Debugger::log('Sending of e-mail failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
192
|
|
|
$this->flashMessage('Sending of e-mail failed, result: ' . $e->getMessage(), 'error'); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
$this->redirect('Visitor:listing'); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* @param integer|string $ids |
|
|
|
|
|
|
200
|
|
|
* @return void |
|
201
|
|
|
*/ |
|
202
|
|
View Code Duplication |
public function actionPay($id) |
|
|
|
|
|
|
203
|
|
|
{ |
|
204
|
|
|
try { |
|
205
|
|
|
$visitor = $this->getModel(); |
|
206
|
|
|
$visitor->payCharge($id, 'cost'); |
|
207
|
|
|
$recipients = $visitor->getRecipients($id); |
|
208
|
|
|
$this->getEmailer()->sendPaymentInfo($recipients, 'advance'); |
|
209
|
|
|
|
|
210
|
|
|
Debugger::log('Visitor: Action pay for id ' . $id . ' successfull, result: ' . $e->getMessage(), Debugger::INFO); |
|
|
|
|
|
|
211
|
|
|
$this->flashMessage('Platba byla zaplacena.', 'ok'); |
|
212
|
|
|
} catch(Exception $e) { |
|
213
|
|
|
Debugger::log('Visitor: Action pay for id ' . $id . ' failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
214
|
|
|
$this->flashMessage('Visitor: Action pay for id ' . $id . ' failed, result: ' . $e->getMessage(), 'error'); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
$this->redirect('Visitor:listing'); |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @param string|interger $ids |
|
|
|
|
|
|
222
|
|
|
* @return void |
|
223
|
|
|
*/ |
|
224
|
|
View Code Duplication |
public function actionAdvance($id) |
|
|
|
|
|
|
225
|
|
|
{ |
|
226
|
|
|
try { |
|
227
|
|
|
$visitor = $this->getModel(); |
|
228
|
|
|
$visitor->payCharge($id, 'advance'); |
|
229
|
|
|
$recipients = $visitor->getRecipients($id); |
|
230
|
|
|
$this->getEmailer()->sendPaymentInfo($recipients, 'advance'); |
|
231
|
|
|
|
|
232
|
|
|
Debugger::log('Visitor: Action advance for id ' . $id . ' successfull, result: ' . $e->getMessage(), Debugger::INFO); |
|
|
|
|
|
|
233
|
|
|
$this->flashMessage('Záloha byla zaplacena.', 'ok'); |
|
234
|
|
|
} catch(Exception $e) { |
|
235
|
|
|
Debugger::log('Visitor: Action advance for id ' . $id . ' failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
236
|
|
|
$this->flashMessage('Visitor: Action advance for id ' . $id . ' failed, result: ' . $e->getMessage(), 'error'); |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
$this->redirect('Visitor:listing'); |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* Set item as checked by id |
|
244
|
|
|
* |
|
245
|
|
|
* @param integer $id |
|
246
|
|
|
* @return void |
|
247
|
|
|
*/ |
|
248
|
|
View Code Duplication |
public function actionChecked($id) |
|
|
|
|
|
|
249
|
|
|
{ |
|
250
|
|
|
try { |
|
251
|
|
|
$result = $this->getModel()->checked($id, '1'); |
|
252
|
|
|
Debugger::log('Check of visitor('. $id .') successfull, result: ' . json_encode($result), Debugger::INFO); |
|
253
|
|
|
$this->flashMessage('Položka byla úspěšně zkontrolována', 'ok'); |
|
254
|
|
|
} catch(Exception $e) { |
|
255
|
|
|
Debugger::log('Check of visitor('. $id .') failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
256
|
|
|
$this->flashMessage('Check of visitor failed, result: ' . $e->getMessage(), 'error'); |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
$this->redirect('Visitor:listing'); |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* Set item as unchecked by id |
|
264
|
|
|
* |
|
265
|
|
|
* @param integer $id |
|
266
|
|
|
* @return void |
|
267
|
|
|
*/ |
|
268
|
|
View Code Duplication |
public function actionUnchecked($id) |
|
|
|
|
|
|
269
|
|
|
{ |
|
270
|
|
|
try { |
|
271
|
|
|
$result = $this->getModel()->checked($id, 0); |
|
272
|
|
|
Debugger::log('Uncheck of visitor('. $id .') successfull, result: ' . json_encode($result), Debugger::INFO); |
|
273
|
|
|
$this->flashMessage('Položka byla nastavena jako nekontrolována', 'ok'); |
|
274
|
|
|
} catch(Exception $e) { |
|
275
|
|
|
Debugger::log('Uncheck of visitor('. $id .') failed, result: ' . $e->getMessage(), Debugger::ERROR); |
|
276
|
|
|
$this->flashMessage('Uncheck of visitor failed, result: ' . $e->getMessage(), 'error'); |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
$this->redirect('Visitor:listing'); |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* Prepare page for new item |
|
284
|
|
|
* |
|
285
|
|
|
* @return void |
|
286
|
|
|
*/ |
|
287
|
|
|
public function renderNew() |
|
288
|
|
|
{ |
|
289
|
|
|
$template = $this->getTemplate(); |
|
290
|
|
|
|
|
291
|
|
|
$template->heading = 'nový účastník'; |
|
|
|
|
|
|
292
|
|
|
$template->error_name = ''; |
|
|
|
|
|
|
293
|
|
|
$template->error_surname = ''; |
|
|
|
|
|
|
294
|
|
|
$template->error_nick = ''; |
|
|
|
|
|
|
295
|
|
|
$template->error_email = ''; |
|
|
|
|
|
|
296
|
|
|
$template->error_postal_code = ''; |
|
|
|
|
|
|
297
|
|
|
$template->error_group_num = ''; |
|
|
|
|
|
|
298
|
|
|
$template->error_bill = ''; |
|
|
|
|
|
|
299
|
|
|
$template->error_cost = ''; |
|
|
|
|
|
|
300
|
|
|
$template->province = $this->getMeetingModel()->renderHtmlProvinceSelect(null); |
|
|
|
|
|
|
301
|
|
|
$template->meals = $this->getMealModel()->renderHtmlMealsSelect(null, null); |
|
|
|
|
|
|
302
|
|
|
$template->cost = $this->getMeetingModel()->getPrice('cost'); |
|
|
|
|
|
|
303
|
|
|
$template->programSwitcher = $this->getModel()->renderProgramSwitcher($this->getMeetingId(), null); |
|
|
|
|
|
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
/** |
|
307
|
|
|
* @param integer $id |
|
308
|
|
|
* @return void |
|
309
|
|
|
*/ |
|
310
|
|
|
public function renderEdit($id) |
|
311
|
|
|
{ |
|
312
|
|
|
$visitor = $this->getModel()->findById($id); |
|
313
|
|
|
$meals = $this->getMealModel()->findByVisitorId($id); |
|
314
|
|
|
|
|
315
|
|
|
$template = $this->getTemplate(); |
|
316
|
|
|
|
|
317
|
|
|
$template->heading = 'úprava účastníka'; |
|
|
|
|
|
|
318
|
|
|
$template->error_name = ''; |
|
|
|
|
|
|
319
|
|
|
$template->error_surname = ''; |
|
|
|
|
|
|
320
|
|
|
$template->error_nick = ''; |
|
|
|
|
|
|
321
|
|
|
$template->error_email = ''; |
|
|
|
|
|
|
322
|
|
|
$template->error_postal_code = ''; |
|
|
|
|
|
|
323
|
|
|
$template->error_group_num = ''; |
|
|
|
|
|
|
324
|
|
|
$template->error_bill = ''; |
|
|
|
|
|
|
325
|
|
|
$template->error_cost = ''; |
|
|
|
|
|
|
326
|
|
|
$template->province = $this->getMeetingModel()->renderHtmlProvinceSelect($visitor->province); |
|
|
|
|
|
|
327
|
|
|
$template->meals = $this->getMealModel()->renderHtmlMealsSelect($meals, null); |
|
|
|
|
|
|
328
|
|
|
$template->cost = $this->getMeetingModel()->getPrice('cost'); |
|
|
|
|
|
|
329
|
|
|
$template->programSwitcher = $this->getModel()->renderProgramSwitcher($this->getMeetingId(), $id); |
|
|
|
|
|
|
330
|
|
|
$template->data = $visitor; |
|
|
|
|
|
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
/** |
|
334
|
|
|
* Prepare mass mail form |
|
335
|
|
|
* |
|
336
|
|
|
* @return void |
|
337
|
|
|
*/ |
|
338
|
|
|
public function renderMail() |
|
339
|
|
|
{ |
|
340
|
|
|
$ids = $this->getRequest()->getPost('checker'); |
|
341
|
|
|
|
|
342
|
|
|
$template = $this->getTemplate(); |
|
343
|
|
|
$template->recipientMailAddresses = $this->getModel()->getSerializedMailAddress($ids); |
|
|
|
|
|
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
|
|
347
|
|
|
/** |
|
348
|
|
|
* @return void |
|
349
|
|
|
*/ |
|
350
|
|
|
public function renderListing() |
|
351
|
|
|
{ |
|
352
|
|
|
$search = $this->getRequest()->getQuery('search'); |
|
353
|
|
|
|
|
354
|
|
|
$model = $this->getModel(); |
|
355
|
|
|
|
|
356
|
|
|
$template = $this->getTemplate(); |
|
357
|
|
|
$template->render = $model->setSearch($search)->all(); |
|
|
|
|
|
|
358
|
|
|
$template->visitorCount = $model->getCount(); |
|
|
|
|
|
|
359
|
|
|
$template->meetingPrice = $this->getMeetingModel()->getPrice('cost'); |
|
|
|
|
|
|
360
|
|
|
$template->search = $search; |
|
|
|
|
|
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* @return Latte |
|
365
|
|
|
*/ |
|
366
|
|
|
protected function createMailTemplate() |
|
367
|
|
|
{ |
|
368
|
|
|
$template = $this->createTemplate(); |
|
369
|
|
|
$template->setFile( |
|
370
|
|
|
sprintf( |
|
371
|
|
|
'%s%s.%s', |
|
372
|
|
|
self::TEMPLATE_DIR, |
|
373
|
|
|
'mail_body', |
|
374
|
|
|
self::TEMPLATE_EXT |
|
375
|
|
|
) |
|
376
|
|
|
); |
|
377
|
|
|
|
|
378
|
|
|
return $template; |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
/** |
|
382
|
|
|
* @param array $visitor |
|
383
|
|
|
* @return boolean |
|
384
|
|
|
*/ |
|
385
|
|
|
protected function sendRegistrationSummary(array $visitor, $guid) |
|
386
|
|
|
{ |
|
387
|
|
|
$recipient = [ |
|
388
|
|
|
$visitor['email'] => $visitor['name']. ' ' . $visitor['surname'], |
|
389
|
|
|
]; |
|
390
|
|
|
|
|
391
|
|
|
$code4bank = $this->calculateCode4Bank($visitor); |
|
392
|
|
|
$result = $this->getEmailer()->sendRegistrationSummary($recipient, $guid, $code4bank); |
|
393
|
|
|
|
|
394
|
|
|
return $result; |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
/** |
|
398
|
|
|
* @param array $data |
|
399
|
|
|
* @return string |
|
400
|
|
|
*/ |
|
401
|
|
|
protected function calculateCode4Bank(array $data) |
|
402
|
|
|
{ |
|
403
|
|
|
return Strings::toAscii( |
|
404
|
|
|
mb_substr($data['name'], 0, 1, 'utf-8') |
|
405
|
|
|
. mb_substr($data['surname'], 0, 1, 'utf-8') |
|
406
|
|
|
. mb_substr($data['birthday'], 2, 2) |
|
407
|
|
|
); |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
/** |
|
411
|
|
|
* @return MeetingModel |
|
412
|
|
|
*/ |
|
413
|
|
|
protected function getMeetingModel() |
|
414
|
|
|
{ |
|
415
|
|
|
return $this->meetingModel; |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
/** |
|
419
|
|
|
* @param MeetingModel $model |
|
420
|
|
|
* @return $this |
|
421
|
|
|
*/ |
|
422
|
|
|
protected function setMeetingModel(MeetingModel $model) |
|
423
|
|
|
{ |
|
424
|
|
|
$this->meetingModel = $model; |
|
425
|
|
|
|
|
426
|
|
|
return $this; |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
/** |
|
430
|
|
|
* @return Emailer |
|
431
|
|
|
*/ |
|
432
|
|
|
protected function getEmailer() |
|
433
|
|
|
{ |
|
434
|
|
|
return $this->emailer; |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
/** |
|
438
|
|
|
* @param Emailer $emailer |
|
439
|
|
|
* @return $this |
|
440
|
|
|
*/ |
|
441
|
|
|
protected function setEmailer(Emailer $emailer) |
|
442
|
|
|
{ |
|
443
|
|
|
$this->emailer = $emailer; |
|
444
|
|
|
|
|
445
|
|
|
return $this; |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
/** |
|
449
|
|
|
* @return MealModel |
|
450
|
|
|
*/ |
|
451
|
|
|
protected function getMealModel() |
|
452
|
|
|
{ |
|
453
|
|
|
return $this->mealModel; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
/** |
|
457
|
|
|
* @param MealModel $model |
|
458
|
|
|
* @return $this |
|
459
|
|
|
*/ |
|
460
|
|
|
protected function setMealModel(MealModel $model) |
|
461
|
|
|
{ |
|
462
|
|
|
$this->mealModel = $model; |
|
463
|
|
|
|
|
464
|
|
|
return $this; |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* @return BlockModel |
|
469
|
|
|
*/ |
|
470
|
|
|
protected function getBlockModel() |
|
471
|
|
|
{ |
|
472
|
|
|
return $this->blockModel; |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
/** |
|
476
|
|
|
* @param BlockModel $model |
|
477
|
|
|
* @return $this |
|
478
|
|
|
*/ |
|
479
|
|
|
protected function setBlockModel(BlockModel $model) |
|
480
|
|
|
{ |
|
481
|
|
|
$this->blockModel = $model; |
|
482
|
|
|
|
|
483
|
|
|
return $this; |
|
484
|
|
|
} |
|
485
|
|
|
|
|
486
|
|
|
/** |
|
487
|
|
|
* @return VisitorService |
|
488
|
|
|
*/ |
|
489
|
|
|
protected function getVisitorService() |
|
490
|
|
|
{ |
|
491
|
|
|
return $this->visitorService; |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
/** |
|
495
|
|
|
* @param VisitorService $service |
|
496
|
|
|
* @return $this |
|
497
|
|
|
*/ |
|
498
|
|
|
protected function setVisitorService(VisitorService $service) |
|
499
|
|
|
{ |
|
500
|
|
|
$this->visitorService = $service; |
|
|
|
|
|
|
501
|
|
|
|
|
502
|
|
|
return $this; |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
} |
|
506
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.