|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
//---------------------------------------------------------------------- |
|
4
|
|
|
// |
|
5
|
|
|
// Copyright (C) 2016 Artem Rodygin |
|
6
|
|
|
// |
|
7
|
|
|
// This file is part of DataTables Symfony bundle. |
|
8
|
|
|
// |
|
9
|
|
|
// You should have received a copy of the MIT License along with |
|
10
|
|
|
// the bundle. If not, see <http://opensource.org/licenses/MIT>. |
|
11
|
|
|
// |
|
12
|
|
|
//---------------------------------------------------------------------- |
|
13
|
|
|
|
|
14
|
|
|
namespace DataTables; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Column parameters as part of DataTables request. |
|
18
|
|
|
* |
|
19
|
|
|
* @see https://www.datatables.net/manual/server-side |
|
20
|
|
|
* |
|
21
|
|
|
* @property-read string $data Column's data source. |
|
22
|
|
|
* @property-read string $name Column's name. |
|
23
|
|
|
* @property-read bool $searchable Flag to indicate if this column is searchable or not. |
|
24
|
|
|
* @property-read bool $orderable Flag to indicate if this column is orderable or not. |
|
25
|
|
|
* @property-read Search $search Search value to apply to this specific column. |
|
26
|
|
|
*/ |
|
27
|
|
|
class Column extends ValueObject implements \JsonSerializable |
|
28
|
|
|
{ |
|
29
|
|
|
protected $data; |
|
30
|
|
|
protected $name; |
|
31
|
|
|
protected $searchable; |
|
32
|
|
|
protected $orderable; |
|
33
|
|
|
protected $search; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Initializing constructor. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $data |
|
39
|
|
|
* @param string $name |
|
40
|
|
|
* @param bool $searchable |
|
41
|
|
|
* @param bool $orderable |
|
42
|
|
|
* @param Search $search |
|
43
|
|
|
*/ |
|
44
|
4 |
|
public function __construct(string $data, string $name, bool $searchable, bool $orderable, Search $search) |
|
45
|
|
|
{ |
|
46
|
4 |
|
$this->data = $data; |
|
47
|
4 |
|
$this->name = $name; |
|
48
|
4 |
|
$this->searchable = $searchable; |
|
49
|
4 |
|
$this->orderable = $orderable; |
|
50
|
4 |
|
$this->search = $search; |
|
51
|
4 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* {@inheritdoc} |
|
55
|
|
|
*/ |
|
56
|
2 |
|
public function jsonSerialize() |
|
57
|
|
|
{ |
|
58
|
|
|
return [ |
|
59
|
2 |
|
'data' => $this->data, |
|
60
|
2 |
|
'name' => $this->name, |
|
61
|
2 |
|
'searchable' => $this->searchable, |
|
62
|
2 |
|
'orderable' => $this->orderable, |
|
63
|
2 |
|
'search' => $this->search->jsonSerialize(), |
|
64
|
|
|
]; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|