|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @company MTE Telecom, Ltd. |
|
4
|
|
|
* @author Roman Malashin <[email protected]> |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Nnx\DataGrid\View\Helper\JqGrid\Column; |
|
8
|
|
|
|
|
9
|
|
|
use Zend\View\Helper\AbstractHelper; |
|
10
|
|
|
use Nnx\DataGrid\Column\ColumnInterface; |
|
11
|
|
|
use Zend\View\Renderer\PhpRenderer; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class Column |
|
15
|
|
|
* @package Nnx\DataGrid\View\Helper |
|
16
|
|
|
*/ |
|
17
|
|
|
class Text extends AbstractHelper |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param ColumnInterface $column |
|
21
|
|
|
* @return string |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __invoke(ColumnInterface $column) |
|
24
|
|
|
{ |
|
25
|
|
|
$config = $this->getColumnConfig($column); |
|
26
|
|
|
$config = array_merge($config, $column->getAttributes()); |
|
27
|
|
|
return (object)$config; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Возвращает конфигурацию колонки |
|
32
|
|
|
* @param ColumnInterface $column |
|
33
|
|
|
* @return array |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function getColumnConfig(ColumnInterface $column) |
|
36
|
|
|
{ |
|
37
|
|
|
/** @var PhpRenderer $view */ |
|
38
|
|
|
$view = $this->getView(); |
|
39
|
|
|
/** @var \Zend\View\Helper\EscapeHtml $escape */ |
|
40
|
|
|
$escape = $view->plugin('escapeHtml'); |
|
41
|
|
|
$name = $escape($column->getName()); |
|
|
|
|
|
|
42
|
|
|
$header = $column->getHeader(); |
|
43
|
|
|
$config = [ |
|
44
|
|
|
'label' => $header ? $escape($header->getTitle()) : null, |
|
45
|
|
|
'index' => strtolower($name), |
|
46
|
|
|
'name' => strtolower($name), |
|
47
|
|
|
]; |
|
48
|
|
|
return $config; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
protected function getAttrValue($key, $attributes, $default = null) |
|
|
|
|
|
|
52
|
|
|
{ |
|
53
|
|
|
return array_key_exists($key, $attributes) ? $attributes[$key] : $default; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
|
|
|
|
|
56
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.