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
|
|
|
|
10
|
|
|
namespace ZfTable\Example\TableExample; |
11
|
|
|
|
12
|
|
|
use ZfTable\AbstractTable; |
13
|
|
|
|
14
|
|
View Code Duplication |
class Template extends AbstractTable |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
protected $config = array( |
18
|
|
|
'name' => 'Template decorator', |
19
|
|
|
'showPagination' => true, |
20
|
|
|
'showQuickSearch' => false, |
21
|
|
|
'showItemPerPage' => true, |
22
|
|
|
'itemCountPerPage' => 10, |
23
|
|
|
); |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var array Definition of headers |
27
|
|
|
*/ |
28
|
|
|
protected $headers = array( |
29
|
|
|
'idcustomer' => array('title' => 'Id', 'width' => '50') , |
30
|
|
|
'name' => array('title' => 'Name' ), |
31
|
|
|
'surname' => array('title' => 'Surname' ), |
32
|
|
|
'street' => array('title' => 'Street'), |
33
|
|
|
'city' => array('title' => 'City' ), |
34
|
|
|
'active' => array('title' => 'Active' , 'width' => 100 ), |
35
|
|
|
); |
36
|
|
|
|
37
|
|
|
public function init() |
38
|
|
|
{ |
39
|
|
|
$this->getHeader('surname')->getCell()->addDecorator('template', array( |
40
|
|
|
'template' => '<strong>%s %s</strong>', |
41
|
|
|
'vars' => array('name', 'surname') |
42
|
|
|
)); |
43
|
|
|
|
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
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.