1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ZfTable ( Module for Zend Framework 2) |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2013 Piotr Duda [email protected] |
6
|
|
|
* @license MIT License |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace ZfTable\Controller; |
10
|
|
|
|
11
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
12
|
|
|
use ZfTable\Example\TableExample; |
13
|
|
|
use Zend\View\Model\ViewModel; |
14
|
|
|
use Zend\Db\ResultSet\ResultSet; |
15
|
|
|
use ZfTable\Params\AdapterDataTables; |
16
|
|
|
use ZfTable\Options\ModuleOptions; |
17
|
|
|
use ZfTable\AbstractTable; |
18
|
|
|
use Doctrine\ORM\EntityManager; |
19
|
|
|
|
20
|
|
|
class TableController extends AbstractActionController |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* |
25
|
|
|
* @var ResultSet |
26
|
|
|
*/ |
27
|
|
|
protected $resultSet; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* |
31
|
|
|
* @var |
32
|
|
|
*/ |
33
|
|
|
protected $customerTable; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* |
37
|
|
|
* @var \Zend\Db\Adapter\Adapter |
38
|
|
|
*/ |
39
|
|
|
protected $dbAdapter; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* |
43
|
|
|
* @var ModuleOptions |
44
|
|
|
*/ |
45
|
|
|
protected $moduleOptions; |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var \Doctrine\ORM\EntityManager |
52
|
|
|
*/ |
53
|
|
|
protected $em; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
* @return \Doctrine\ORM\EntityManager |
58
|
|
|
*/ |
59
|
|
|
public function getEntityManager() |
60
|
|
|
{ |
61
|
|
|
if (null === $this->em) { |
62
|
|
|
$this->em = $this->getServiceLocator()->get('doctrine.entitymanager.zftable_default'); |
63
|
|
|
} |
64
|
|
|
return $this->em; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function changesAction() |
68
|
|
|
{ |
69
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function bootstrapAction() |
73
|
|
|
{ |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* ********* Additional Params ******************* |
78
|
|
|
* *********************************** |
79
|
|
|
*/ |
80
|
|
|
public function additionalParamsAction() |
81
|
|
|
{ |
82
|
|
|
} |
83
|
|
View Code Duplication |
public function ajaxadditionalParamsAction() |
|
|
|
|
84
|
|
|
{ |
85
|
|
|
$table = new TableExample\AdditionalParams(); |
86
|
|
|
$table->setAdapter($this->getDbAdapter()) |
87
|
|
|
->setSource($this->getSource()) |
88
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
89
|
|
|
; |
90
|
|
|
return $this->htmlResponse($table->render()); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* ********* Javascript Events ******************* |
95
|
|
|
* *********************************** |
96
|
|
|
*/ |
97
|
|
|
public function javascriptEventsAction() |
98
|
|
|
{ |
99
|
|
|
} |
100
|
|
View Code Duplication |
public function ajaxJavascriptEventsAction() |
|
|
|
|
101
|
|
|
{ |
102
|
|
|
$table = new TableExample\JavascriptEvents(); |
103
|
|
|
$table->setAdapter($this->getDbAdapter()) |
104
|
|
|
->setSource($this->getSource()) |
105
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
106
|
|
|
; |
107
|
|
|
return $this->htmlResponse($table->render()); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* ********* Array Adapter ******************* |
113
|
|
|
* ***************************************** |
114
|
|
|
*/ |
115
|
|
|
public function arrayAction() |
116
|
|
|
{ |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function ajaxArrayAction() |
120
|
|
|
{ |
121
|
|
|
$table = new TableExample\ArrayAdapter(); |
122
|
|
|
|
123
|
|
|
$sql = new \Zend\Db\Sql\Sql($this->getDbAdapter()); |
124
|
|
|
|
125
|
|
|
$stmt = $sql->prepareStatementForSqlObject($this->getSource()); |
126
|
|
|
$res = $stmt->execute(); |
127
|
|
|
|
128
|
|
|
$resultSet = new \Zend\Db\ResultSet\ResultSet(); |
129
|
|
|
$resultSet->initialize($res); |
130
|
|
|
|
131
|
|
|
$source = $resultSet->toArray(); |
132
|
|
|
|
133
|
|
|
$table->setAdapter($this->getDbAdapter()) |
134
|
|
|
->setSource($source) |
135
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
136
|
|
|
; |
137
|
|
|
return $this->htmlResponse($table->render()); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* ********* Doctrine Adapter ******************* |
143
|
|
|
* ***************************************** |
144
|
|
|
*/ |
145
|
|
|
public function doctrineAction() |
146
|
|
|
{ |
147
|
|
|
} |
148
|
|
|
public function ajaxDoctrineAction() |
149
|
|
|
{ |
150
|
|
|
$table = new TableExample\Doctrine(); |
151
|
|
|
$form = $table->getForm(); |
152
|
|
|
|
153
|
|
|
//I don't know if it necesary to validate that request is POST |
154
|
|
|
$request = $this->getRequest(); |
155
|
|
|
|
156
|
|
|
$filter = $table->getFilter(); |
157
|
|
|
$form->setInputFilter($filter); |
158
|
|
|
$form->setData($request->getPost()); |
159
|
|
|
|
160
|
|
|
//Optional |
161
|
|
|
if ($form->isValid()) { |
162
|
|
|
$em = $this->getEntityManager(); |
163
|
|
|
$queryBuilder = $em->createQueryBuilder(); |
164
|
|
|
$queryBuilder->add('select', 'p , q') |
165
|
|
|
->add('from', '\ZfTable\Entity\Customer q') |
166
|
|
|
->leftJoin('q.product', 'p') |
167
|
|
|
; |
168
|
|
|
|
169
|
|
|
$table->setAdapter($this->getDbAdapter()) |
170
|
|
|
->setSource($queryBuilder) |
171
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
172
|
|
|
; |
173
|
|
|
|
174
|
|
|
return $this->htmlResponse($table->render()); |
175
|
|
|
} else { |
176
|
|
|
//Indication the wrong data currently not supported |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* ********* Callable ******************* |
184
|
|
|
* ***************************************** |
185
|
|
|
*/ |
186
|
|
|
public function callableAction() |
187
|
|
|
{ |
188
|
|
|
} |
189
|
|
View Code Duplication |
public function ajaxCallableAction() |
|
|
|
|
190
|
|
|
{ |
191
|
|
|
$table = new TableExample\CallableTable(); |
192
|
|
|
$table->setAdapter($this->getDbAdapter()) |
193
|
|
|
->setSource($this->getSource()) |
194
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
195
|
|
|
; |
196
|
|
|
return $this->htmlResponse($table->render()); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
|
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* ********* Column filtering ******************* |
203
|
|
|
* *********************************** |
204
|
|
|
*/ |
205
|
|
|
public function columnFilteringAction() |
206
|
|
|
{ |
207
|
|
|
} |
208
|
|
View Code Duplication |
public function ajaxColumnFilteringAction() |
|
|
|
|
209
|
|
|
{ |
210
|
|
|
$table = new TableExample\ColumnFiltering(); |
211
|
|
|
$table->setAdapter($this->getDbAdapter()) |
212
|
|
|
->setSource($this->getSource()) |
213
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
214
|
|
|
; |
215
|
|
|
return $this->htmlResponse($table->render()); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* ********* Editable tabble ******************* |
221
|
|
|
* *********************************** |
222
|
|
|
*/ |
223
|
|
|
public function editableAction() |
224
|
|
|
{ |
225
|
|
|
} |
226
|
|
View Code Duplication |
public function ajaxEditableAction() |
|
|
|
|
227
|
|
|
{ |
228
|
|
|
$table = new TableExample\Editable(); |
229
|
|
|
$table->setAdapter($this->getDbAdapter()) |
230
|
|
|
->setSource($this->getSource()) |
231
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
232
|
|
|
; |
233
|
|
|
return $this->htmlResponse($table->render()); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
public function updateRowAction() |
237
|
|
|
{ |
238
|
|
|
$param = $this->getRequest()->getPost(); |
239
|
|
|
$this->getCustomerTable()->update( |
240
|
|
|
array($param['column'] => $param['value']), |
241
|
|
|
array('idcustomer' => $param['row']) |
242
|
|
|
); |
243
|
|
|
return $this->jsonResponse(array('success' => 1)); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* ********* Export To CSV ******************* |
249
|
|
|
* ***************************************** |
250
|
|
|
*/ |
251
|
|
|
public function csvExportAction() |
252
|
|
|
{ |
253
|
|
|
} |
254
|
|
View Code Duplication |
public function ajaxCsvExportAction() |
|
|
|
|
255
|
|
|
{ |
256
|
|
|
$table = new TableExample\CsvExport(); |
257
|
|
|
$table->setAdapter($this->getDbAdapter()) |
258
|
|
|
->setSource($this->getSource()) |
259
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
260
|
|
|
; |
261
|
|
|
return $this->htmlResponse($table->render()); |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* ********* SEPARATABLE ******************* |
266
|
|
|
* ***************************************** |
267
|
|
|
*/ |
268
|
|
|
public function separatableAction() |
269
|
|
|
{ |
270
|
|
|
} |
271
|
|
|
public function ajaxSeparatableAction() |
272
|
|
|
{ |
273
|
|
|
$source = $this->getSource(); |
274
|
|
|
$source->order('city ASC'); |
275
|
|
|
|
276
|
|
|
$table = new TableExample\Separatable(); |
277
|
|
|
$table->setAdapter($this->getDbAdapter()) |
278
|
|
|
->setSource($source) |
279
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
280
|
|
|
; |
281
|
|
|
return $this->htmlResponse($table->render()); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* ********* Variable Row Attr ******************* |
286
|
|
|
* ***************************************** |
287
|
|
|
*/ |
288
|
|
|
public function variableAttrRowAction() |
289
|
|
|
{ |
290
|
|
|
|
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* ********* New plugin condition ******************* |
295
|
|
|
* ***************************************** |
296
|
|
|
*/ |
297
|
|
|
public function newPluginConditionAction() |
298
|
|
|
{ |
299
|
|
|
|
300
|
|
|
} |
301
|
|
View Code Duplication |
public function ajaxNewPluginConditionAction() |
|
|
|
|
302
|
|
|
{ |
303
|
|
|
$table = new TableExample\NewPluginCondition(); |
304
|
|
|
$table->setAdapter($this->getDbAdapter()) |
305
|
|
|
->setSource($this->getSource()) |
306
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
307
|
|
|
; |
308
|
|
|
return $this->htmlResponse($table->render()); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
|
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* ********* Base ******************* |
315
|
|
|
* *********************************** |
316
|
|
|
*/ |
317
|
|
|
public function baseAction() |
318
|
|
|
{ |
319
|
|
|
} |
320
|
|
View Code Duplication |
public function ajaxBaseAction() |
|
|
|
|
321
|
|
|
{ |
322
|
|
|
$table = new TableExample\Base(); |
323
|
|
|
$table->setAdapter($this->getDbAdapter()) |
324
|
|
|
->setSource($this->getSource()) |
325
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
326
|
|
|
; |
327
|
|
|
return $this->htmlResponse($table->render()); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* ********* Mapper ******************* |
333
|
|
|
* *********************************** |
334
|
|
|
*/ |
335
|
|
|
public function mapperAction() |
336
|
|
|
{ |
337
|
|
|
|
338
|
|
|
} |
339
|
|
|
|
340
|
|
View Code Duplication |
public function ajaxMapperAction() |
|
|
|
|
341
|
|
|
{ |
342
|
|
|
$table = new TableExample\Mapper(); |
343
|
|
|
$table->setAdapter($this->getDbAdapter()) |
344
|
|
|
->setSource($this->getSource()) |
345
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
346
|
|
|
; |
347
|
|
|
return $this->htmlResponse($table->render()); |
348
|
|
|
|
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* ********* Link ******************* |
353
|
|
|
* *********************************** |
354
|
|
|
*/ |
355
|
|
|
public function linkAction() |
356
|
|
|
{ |
357
|
|
|
|
358
|
|
|
} |
359
|
|
|
|
360
|
|
View Code Duplication |
public function ajaxLinkAction() |
|
|
|
|
361
|
|
|
{ |
362
|
|
|
$table = new TableExample\Link(); |
363
|
|
|
$table->setAdapter($this->getDbAdapter()) |
364
|
|
|
->setSource($this->getSource()) |
365
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
366
|
|
|
; |
367
|
|
|
return $this->htmlResponse($table->render()); |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* ********* Template ******************* |
373
|
|
|
* *********************************** |
374
|
|
|
*/ |
375
|
|
|
public function templateAction() |
376
|
|
|
{ |
377
|
|
|
|
378
|
|
|
} |
379
|
|
|
|
380
|
|
View Code Duplication |
public function ajaxTemplateAction() |
|
|
|
|
381
|
|
|
{ |
382
|
|
|
$table = new TableExample\Template(); |
383
|
|
|
$table->setAdapter($this->getDbAdapter()) |
384
|
|
|
->setSource($this->getSource()) |
385
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
386
|
|
|
; |
387
|
|
|
return $this->htmlResponse($table->render()); |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* ********* Attr ******************* |
393
|
|
|
* *********************************** |
394
|
|
|
*/ |
395
|
|
|
public function attrAction() |
396
|
|
|
{ |
397
|
|
|
|
398
|
|
|
} |
399
|
|
|
|
400
|
|
View Code Duplication |
public function ajaxAttrAction() |
|
|
|
|
401
|
|
|
{ |
402
|
|
|
$table = new TableExample\Attr(); |
403
|
|
|
$table->setAdapter($this->getDbAdapter()) |
404
|
|
|
->setSource($this->getSource()) |
405
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
406
|
|
|
; |
407
|
|
|
return $this->htmlResponse($table->render()); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* ********* Condition ******************* |
413
|
|
|
* *********************************** |
414
|
|
|
*/ |
415
|
|
|
public function conditionAction() |
416
|
|
|
{ |
417
|
|
|
|
418
|
|
|
} |
419
|
|
|
|
420
|
|
View Code Duplication |
public function ajaxConditionAction() |
|
|
|
|
421
|
|
|
{ |
422
|
|
|
$table = new TableExample\Condition(); |
423
|
|
|
$table->setAdapter($this->getDbAdapter()) |
424
|
|
|
->setSource($this->getSource()) |
425
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
426
|
|
|
; |
427
|
|
|
return $this->htmlResponse($table->render()); |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* ********* Mix ******************* |
433
|
|
|
* *********************************** |
434
|
|
|
*/ |
435
|
|
|
public function mixAction() |
436
|
|
|
{ |
437
|
|
|
|
438
|
|
|
} |
439
|
|
|
|
440
|
|
View Code Duplication |
public function ajaxMixAction() |
|
|
|
|
441
|
|
|
{ |
442
|
|
|
$table = new TableExample\Mix(); |
443
|
|
|
$table->setAdapter($this->getDbAdapter()) |
444
|
|
|
->setSource($this->getSource()) |
445
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
446
|
|
|
; |
447
|
|
|
return $this->htmlResponse($table->render()); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* ********* Advance ******************* |
452
|
|
|
* *********************************** |
453
|
|
|
*/ |
454
|
|
|
public function advanceAction() |
455
|
|
|
{ |
456
|
|
|
|
457
|
|
|
} |
458
|
|
|
|
459
|
|
View Code Duplication |
public function ajaxAdvanceAction() |
|
|
|
|
460
|
|
|
{ |
461
|
|
|
$table = new TableExample\Advance(); |
462
|
|
|
$table->setAdapter($this->getDbAdapter()) |
463
|
|
|
->setSource($this->getSource()) |
464
|
|
|
->setParamAdapter($this->getRequest()->getPost()) |
465
|
|
|
; |
466
|
|
|
return $this->htmlResponse($table->render('custom', 'custom-b3')); |
467
|
|
|
|
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
|
471
|
|
|
|
472
|
|
|
|
473
|
|
|
|
474
|
|
|
|
475
|
|
|
|
476
|
|
|
/************************************************ */ |
477
|
|
|
/*************** EXAMPLE DATA TABLE ************* */ |
478
|
|
|
|
479
|
|
|
public function dataTableAction() |
480
|
|
|
{ |
481
|
|
|
$source = $this->getSource(); |
482
|
|
|
$table = new TableExample\DataTable(); |
483
|
|
|
$table->setAdapter($this->getDbAdapter()) |
484
|
|
|
->setSource($source) |
485
|
|
|
->setParamAdapter(new AdapterDataTables($this->getRequest()->getPost())) |
486
|
|
|
; |
487
|
|
|
|
488
|
|
|
return new ViewModel(array( |
489
|
|
|
'tableDataTable' => $table, |
490
|
|
|
)); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
public function ajaxDataTableAction() |
494
|
|
|
{ |
495
|
|
|
$source = $this->getSource(); |
496
|
|
|
$table = new TableExample\DataTable(); |
497
|
|
|
$table->setAdapter($this->getDbAdapter()) |
498
|
|
|
->setSource($source) |
499
|
|
|
->setParamAdapter(new AdapterDataTables($this->getRequest()->getPost())) |
500
|
|
|
; |
501
|
|
|
|
502
|
|
|
$response = $this->getResponse(); |
503
|
|
|
$response->setStatusCode(200); |
504
|
|
|
$response->setContent($table->render('dataTableJson')); |
505
|
|
|
return $response; |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
|
509
|
|
|
public function htmlResponse($html) |
510
|
|
|
{ |
511
|
|
|
$response = $this->getResponse(); |
512
|
|
|
$response->setStatusCode(200); |
513
|
|
|
$response->setContent($html); |
514
|
|
|
return $response; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
public function jsonResponse($data) |
518
|
|
|
{ |
519
|
|
|
if (!is_array($data)) { |
520
|
|
|
throw new \InvalidArgumentException('$data param must be array'); |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
$response = $this->getResponse(); |
524
|
|
|
$response->setStatusCode(200); |
525
|
|
|
$response->setContent(json_encode($data)); |
526
|
|
|
return $response; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* |
532
|
|
|
* @return \ZfTable\Example\Model\CustomerTable |
533
|
|
|
* |
534
|
|
|
*/ |
535
|
|
|
public function getCustomerTable() |
536
|
|
|
{ |
537
|
|
|
if (!$this->customerTable) { |
538
|
|
|
$sm = $this->getServiceLocator(); |
539
|
|
|
$this->customerTable = $sm->get('ZfTable\Example\Model\CustomerTable'); |
540
|
|
|
} |
541
|
|
|
return $this->customerTable; |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/**********************My codes*********************/ |
545
|
|
|
|
546
|
|
|
|
547
|
|
|
|
548
|
|
|
public function institutionRequestsAction() |
549
|
|
|
{ |
550
|
|
|
} |
551
|
|
|
|
552
|
|
View Code Duplication |
public function ajaxInstitutionRequestsAction() |
|
|
|
|
553
|
|
|
{ |
554
|
|
|
$table = new TableExample\InstitutionRequests(); |
555
|
|
|
$table->setAdapter($this->getDbAdapter()) |
556
|
|
|
->setSource($this->getInstitutionRequests()) |
557
|
|
|
->setParamAdapter($this->getRequest()->getPost()); |
558
|
|
|
return $this->htmlResponse($table->render()); |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
/** |
562
|
|
|
* @return \Zend\Db\Sql\Select Type |
563
|
|
|
*/ |
564
|
|
|
private function getInstitutionRequests() |
565
|
|
|
{ |
566
|
|
|
return $this->getCustomerTable()->fetchAllInstitutionRequests(); |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
|
570
|
|
|
|
571
|
|
|
/** |
572
|
|
|
* |
573
|
|
|
* @return \Zend\Db\Adapter\Adapter |
574
|
|
|
*/ |
575
|
|
|
public function getDbAdapter() |
576
|
|
|
{ |
577
|
|
|
if (!$this->dbAdapter) { |
578
|
|
|
$sm = $this->getServiceLocator(); |
579
|
|
|
$this->dbAdapter = $sm->get('zfdb_adapter'); |
580
|
|
|
} |
581
|
|
|
return $this->dbAdapter; |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
/** |
585
|
|
|
* |
586
|
|
|
* @return \Zend\Db\Sql\Select |
587
|
|
|
*/ |
588
|
|
|
private function getSource() |
589
|
|
|
{ |
590
|
|
|
return $this->getCustomerTable()->fetchAllSelect(); |
591
|
|
|
} |
592
|
|
|
} |
593
|
|
|
|
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.