1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LAG\AdminBundle\Admin; |
4
|
|
|
|
5
|
|
|
use LAG\AdminBundle\Action\Configuration\ActionConfiguration; |
6
|
|
|
use LAG\AdminBundle\Field\Field; |
7
|
|
|
|
8
|
|
|
class Action implements ActionInterface |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Action name. |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
protected $name; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Action title. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $title; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Fields displayed for this action. |
26
|
|
|
* |
27
|
|
|
* @var Field[] |
28
|
|
|
*/ |
29
|
|
|
protected $fields = []; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Action permissions. |
33
|
|
|
* |
34
|
|
|
* @var string[] |
35
|
|
|
*/ |
36
|
|
|
protected $permissions = []; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var ActionConfiguration |
40
|
|
|
*/ |
41
|
|
|
protected $configuration; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var array |
45
|
|
|
*/ |
46
|
|
|
protected $filters = []; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Action constructor. |
50
|
|
|
* |
51
|
|
|
* @param $actionName |
52
|
|
|
* @param ActionConfiguration $configuration |
53
|
|
|
*/ |
54
|
|
|
public function __construct($actionName, ActionConfiguration $configuration) |
55
|
|
|
{ |
56
|
|
|
$this->configuration = $configuration; |
57
|
|
|
$this->name = $actionName; |
58
|
|
|
$this->title = $configuration->getParameter('title'); |
59
|
|
|
$this->permissions = $configuration->getParameter('permissions'); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getName() |
66
|
|
|
{ |
67
|
|
|
return $this->name; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getTitle() |
74
|
5 |
|
{ |
75
|
|
|
return $this->title; |
76
|
5 |
|
} |
77
|
5 |
|
|
78
|
5 |
|
/** |
79
|
5 |
|
* @return Field[] |
80
|
5 |
|
*/ |
81
|
5 |
|
public function getFields() |
82
|
5 |
|
{ |
83
|
|
|
return $this->fields; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
5 |
|
* Return true if action has a field named $fieldName. |
88
|
|
|
* |
89
|
5 |
|
* @param string $fieldName |
90
|
|
|
* |
91
|
|
|
* @return bool |
92
|
|
|
*/ |
93
|
|
|
public function hasField($fieldName) |
94
|
|
|
{ |
95
|
1 |
|
return array_key_exists($fieldName, $this->fields); |
96
|
|
|
} |
97
|
1 |
|
|
98
|
|
|
/** |
99
|
|
|
* @param Field[] $fields |
100
|
|
|
*/ |
101
|
|
|
public function setFields($fields) |
102
|
|
|
{ |
103
|
1 |
|
$this->fields = $fields; |
104
|
|
|
} |
105
|
1 |
|
|
106
|
|
|
/** |
107
|
|
|
* @param Field $field |
108
|
|
|
*/ |
109
|
|
|
public function addField(Field $field) |
110
|
|
|
{ |
111
|
|
|
$this->fields[$field->getName()] = $field; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return string[] |
116
|
|
|
*/ |
117
|
|
|
public function getPermissions() |
118
|
|
|
{ |
119
|
|
|
return $this->permissions; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return array |
124
|
|
|
*/ |
125
|
|
|
public function getFilters() |
126
|
|
|
{ |
127
|
|
|
return $this->filters; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
1 |
|
* @param array $filters |
132
|
|
|
*/ |
133
|
1 |
|
public function setFilters($filters) |
134
|
1 |
|
{ |
135
|
|
|
$this->filters = $filters; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
1 |
|
* @param Filter $filter |
140
|
|
|
*/ |
141
|
1 |
|
public function addFilter(Filter $filter) |
142
|
|
|
{ |
143
|
|
|
$this->filters[] = $filter; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
1 |
|
* @return ActionConfiguration |
148
|
|
|
*/ |
149
|
1 |
|
public function getConfiguration() |
150
|
|
|
{ |
151
|
|
|
return $this->configuration; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..