@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @inheritdoc |
32 | 32 | */ |
33 | - public function listClasses(&$paginator=[], $filters=[], $orderBy=[], $includeDeleted=false) |
|
33 | + public function listClasses(&$paginator = [], $filters = [], $orderBy = [], $includeDeleted = false) |
|
34 | 34 | { |
35 | 35 | // check the inputs |
36 | 36 | $paginator = $this->createPaginator($paginator); |
37 | - $orderBy = count($orderBy)>0 ? $orderBy : 'label ASC'; |
|
38 | - $filters = array_intersect_key($filters, array_flip(['class_type','label','description','module'])); |
|
37 | + $orderBy = count($orderBy) > 0 ? $orderBy : 'label ASC'; |
|
38 | + $filters = array_intersect_key($filters, array_flip(['class_type', 'label', 'description', 'module'])); |
|
39 | 39 | if (isset($filters['class_type'])) |
40 | 40 | $filters['class_type'] = $this->canonicaliseRef($filters['class_type']); |
41 | 41 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $query->select($select); |
64 | 64 | foreach ($filters as $key=>$value) |
65 | 65 | $query->andWhere(['like', "p1.$key", $value]); |
66 | - if ($paginator['start']==0) |
|
66 | + if ($paginator['start'] == 0) |
|
67 | 67 | $paginator['total'] = $query->count(); |
68 | 68 | |
69 | 69 | // and get the results |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * @inheritdoc |
84 | 84 | */ |
85 | - public function addClass(&$classType, $module='') |
|
85 | + public function addClass(&$classType, $module = '') |
|
86 | 86 | { |
87 | 87 | $classType = $this->canonicaliseRef($classType); |
88 | 88 | if (empty($classType)) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @inheritdoc |
108 | 108 | */ |
109 | - public function getClass($classType, $version=null, $classOverrideCriteria=[]) |
|
109 | + public function getClass($classType, $version = null, $classOverrideCriteria = []) |
|
110 | 110 | { |
111 | 111 | $classType = $this->canonicaliseRef($classType); |
112 | 112 | if (empty($classType)) |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * @inheritdoc |
163 | 163 | */ |
164 | - public function listObjects($classType, &$paginator=[], $filters=[], $orderBy=[], $additionalFields=[]) |
|
164 | + public function listObjects($classType, &$paginator = [], $filters = [], $orderBy = [], $additionalFields = []) |
|
165 | 165 | { |
166 | 166 | |
167 | 167 | // check the inputs |
168 | 168 | $classType = $this->canonicaliseRef($classType); |
169 | 169 | $paginator = $this->createPaginator($paginator); |
170 | - $orderBy = count($orderBy)>0 ? $orderBy : 'created DESC'; |
|
171 | - $filters = array_intersect_key($filters, array_flip(['version','created','updated'])); |
|
170 | + $orderBy = count($orderBy) > 0 ? $orderBy : 'created DESC'; |
|
171 | + $filters = array_intersect_key($filters, array_flip(['version', 'created', 'updated'])); |
|
172 | 172 | |
173 | 173 | $query = ObjectModel::find()->where([ |
174 | 174 | 'phoebe_type' => $this->getPhoebeType(), |
175 | 175 | 'class_type' => $classType |
176 | 176 | ]); |
177 | - $select = ['uuid','phoebe_type','class_type','version','created','updated']; |
|
177 | + $select = ['uuid', 'phoebe_type', 'class_type', 'version', 'created', 'updated']; |
|
178 | 178 | |
179 | 179 | if (in_array('data', $additionalFields)) |
180 | 180 | $select[] = 'serialised_data'; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | foreach ($filters as $key=>$value) |
189 | 189 | $query->andWhere(['=', $key, $value]); |
190 | - if ($paginator['start']==0) |
|
190 | + if ($paginator['start'] == 0) |
|
191 | 191 | $paginator['total'] = $query->count(); |
192 | 192 | // and get the results |
193 | 193 | return $query->offset($paginator['start']) |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | /** |
201 | 201 | * @inheritdoc |
202 | 202 | */ |
203 | - public function addObject($classType, $classOverrideCriteria=[]) |
|
203 | + public function addObject($classType, $classOverrideCriteria = []) |
|
204 | 204 | { |
205 | 205 | $class = $this->getClassFromType($classType); |
206 | 206 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * created automatically or if false then it is left as null. |
308 | 308 | * @return neon\phoebe\services\adapters\common\models\PhoebeObject |
309 | 309 | */ |
310 | - protected function createPhoebeObjectModel($classType, $uuid=null) |
|
310 | + protected function createPhoebeObjectModel($classType, $uuid = null) |
|
311 | 311 | { |
312 | 312 | // create a model for the class |
313 | 313 | $model = new ObjectModel(); |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | $paginator = $this->createPaginator($paginator); |
37 | 37 | $orderBy = count($orderBy)>0 ? $orderBy : 'label ASC'; |
38 | 38 | $filters = array_intersect_key($filters, array_flip(['class_type','label','description','module'])); |
39 | - if (isset($filters['class_type'])) |
|
40 | - $filters['class_type'] = $this->canonicaliseRef($filters['class_type']); |
|
39 | + if (isset($filters['class_type'])) { |
|
40 | + $filters['class_type'] = $this->canonicaliseRef($filters['class_type']); |
|
41 | + } |
|
41 | 42 | |
42 | 43 | /* |
43 | 44 | * This slightly unusual query according to MySQL is an efficient way to find the highest version of |
@@ -61,10 +62,12 @@ discard block |
||
61 | 62 | $query->andWhere(['p1.deleted'=>0]); |
62 | 63 | } |
63 | 64 | $query->select($select); |
64 | - foreach ($filters as $key=>$value) |
|
65 | - $query->andWhere(['like', "p1.$key", $value]); |
|
66 | - if ($paginator['start']==0) |
|
67 | - $paginator['total'] = $query->count(); |
|
65 | + foreach ($filters as $key=>$value) { |
|
66 | + $query->andWhere(['like', "p1.$key", $value]); |
|
67 | + } |
|
68 | + if ($paginator['start']==0) { |
|
69 | + $paginator['total'] = $query->count(); |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // and get the results |
70 | 73 | $results = $query->offset($paginator['start']) |
@@ -74,8 +77,9 @@ discard block |
||
74 | 77 | |
75 | 78 | // finally index them by the class_type as this is useful for changes in other classes |
76 | 79 | $return = []; |
77 | - foreach ($results as $r) |
|
78 | - $return[$r['class_type']] = $r; |
|
80 | + foreach ($results as $r) { |
|
81 | + $return[$r['class_type']] = $r; |
|
82 | + } |
|
79 | 83 | return $return; |
80 | 84 | } |
81 | 85 | |
@@ -85,8 +89,9 @@ discard block |
||
85 | 89 | public function addClass(&$classType, $module='') |
86 | 90 | { |
87 | 91 | $classType = $this->canonicaliseRef($classType); |
88 | - if (empty($classType)) |
|
89 | - throw new \RuntimeException("Invalid classType $classType"); |
|
92 | + if (empty($classType)) { |
|
93 | + throw new \RuntimeException("Invalid classType $classType"); |
|
94 | + } |
|
90 | 95 | |
91 | 96 | // create a model for the class |
92 | 97 | $model = $this->createPhoebeClassModel($classType, $module); |
@@ -94,8 +99,9 @@ discard block |
||
94 | 99 | try { |
95 | 100 | if ($model->save()) { |
96 | 101 | $class = $this->createIPhoebeClass($model); |
97 | - } else |
|
98 | - throw new \Exception('Errors on save'); |
|
102 | + } else { |
|
103 | + throw new \Exception('Errors on save'); |
|
104 | + } |
|
99 | 105 | } catch (\Exception $e) { |
100 | 106 | throw new \RuntimeException('Failed to create model. Exception was "'.$e->getMessage().'". Model errors were '.print_r($model->errors, true)); |
101 | 107 | } |
@@ -109,16 +115,18 @@ discard block |
||
109 | 115 | public function getClass($classType, $version=null, $classOverrideCriteria=[]) |
110 | 116 | { |
111 | 117 | $classType = $this->canonicaliseRef($classType); |
112 | - if (empty($classType)) |
|
113 | - return null; |
|
118 | + if (empty($classType)) { |
|
119 | + return null; |
|
120 | + } |
|
114 | 121 | |
115 | 122 | $model = $this->getClassModel($classType, $version); |
116 | 123 | if ($model) { |
117 | 124 | $class = $this->createIPhoebeClass($model); |
118 | 125 | if ($classOverrideCriteria !== false) { |
119 | 126 | $override = $class->findClassOverride($classOverrideCriteria); |
120 | - if ($override) |
|
121 | - $class->applyClassOverrideByDefinition($override['overrides']); |
|
127 | + if ($override) { |
|
128 | + $class->applyClassOverrideByDefinition($override['overrides']); |
|
129 | + } |
|
122 | 130 | } |
123 | 131 | return $class; |
124 | 132 | } |
@@ -132,8 +140,9 @@ discard block |
||
132 | 140 | { |
133 | 141 | $models = $this->getClassModels($classTypes); |
134 | 142 | $classes = array(); |
135 | - foreach ($models as $type => $model) |
|
136 | - $classes[$type] = $model ? $this->createIPhoebeClass($model) : null; |
|
143 | + foreach ($models as $type => $model) { |
|
144 | + $classes[$type] = $model ? $this->createIPhoebeClass($model) : null; |
|
145 | + } |
|
137 | 146 | return $classes; |
138 | 147 | } |
139 | 148 | |
@@ -176,8 +185,9 @@ discard block |
||
176 | 185 | ]); |
177 | 186 | $select = ['uuid','phoebe_type','class_type','version','created','updated']; |
178 | 187 | |
179 | - if (in_array('data', $additionalFields)) |
|
180 | - $select[] = 'serialised_data'; |
|
188 | + if (in_array('data', $additionalFields)) { |
|
189 | + $select[] = 'serialised_data'; |
|
190 | + } |
|
181 | 191 | if (in_array('deleted', $additionalFields)) { |
182 | 192 | $select[] = 'deleted'; |
183 | 193 | } else { |
@@ -185,10 +195,12 @@ discard block |
||
185 | 195 | } |
186 | 196 | $query->select($select); |
187 | 197 | |
188 | - foreach ($filters as $key=>$value) |
|
189 | - $query->andWhere(['=', $key, $value]); |
|
190 | - if ($paginator['start']==0) |
|
191 | - $paginator['total'] = $query->count(); |
|
198 | + foreach ($filters as $key=>$value) { |
|
199 | + $query->andWhere(['=', $key, $value]); |
|
200 | + } |
|
201 | + if ($paginator['start']==0) { |
|
202 | + $paginator['total'] = $query->count(); |
|
203 | + } |
|
192 | 204 | // and get the results |
193 | 205 | return $query->offset($paginator['start']) |
194 | 206 | ->limit($paginator['length']) |
@@ -215,13 +227,15 @@ discard block |
||
215 | 227 | // work out what class override needs to be applied |
216 | 228 | if ($classOverrideCriteria !== false) { |
217 | 229 | $override = $phoebeObject->findClassOverride($classOverrideCriteria, ['uuid']); |
218 | - if ($override) |
|
219 | - $model->override_uuid = $override['uuid']; |
|
230 | + if ($override) { |
|
231 | + $model->override_uuid = $override['uuid']; |
|
232 | + } |
|
220 | 233 | $model->save(); |
221 | 234 | } |
222 | 235 | return $phoebeObject; |
223 | - } else |
|
224 | - throw new \Exception('Errors on save'); |
|
236 | + } else { |
|
237 | + throw new \Exception('Errors on save'); |
|
238 | + } |
|
225 | 239 | } catch (\Exception $e) { |
226 | 240 | throw new \RuntimeException('Failed to create model. Exception was "'.$e->getMessage().'". Model errors were '.print_r($model->errors, true)); |
227 | 241 | } |
@@ -252,13 +266,15 @@ discard block |
||
252 | 266 | protected function getClassFromType($classType) |
253 | 267 | { |
254 | 268 | $classType = $this->canonicaliseRef($classType); |
255 | - if (empty($classType)) |
|
256 | - throw new \RuntimeException("Invalid classType '$classType'"); |
|
269 | + if (empty($classType)) { |
|
270 | + throw new \RuntimeException("Invalid classType '$classType'"); |
|
271 | + } |
|
257 | 272 | |
258 | 273 | // check a class of this classType exists |
259 | 274 | $class = $this->getClassModel($classType); |
260 | - if (!$class) |
|
261 | - throw new \RuntimeException("No class of type '$classType' available"); |
|
275 | + if (!$class) { |
|
276 | + throw new \RuntimeException("No class of type '$classType' available"); |
|
277 | + } |
|
262 | 278 | return $class; |
263 | 279 | } |
264 | 280 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function toArray() |
67 | 67 | { |
68 | - $model = $this->getModel(); |
|
68 | + $model = $this->getModel(); |
|
69 | 69 | return $model ? $model->toArray() : []; |
70 | 70 | } |
71 | 71 | |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | * 'start', 'length', and 'total' |
144 | 144 | * @return array |
145 | 145 | */ |
146 | - protected function createPaginator($paginator=[]) |
|
146 | + protected function createPaginator($paginator = []) |
|
147 | 147 | { |
148 | 148 | return [ |
149 | - 'start'=> (isset($paginator['start']) ? max(0, (int)$paginator['start']) : 0), |
|
150 | - 'length'=> (isset($paginator['length']) ? max(1,min(self::CLASS_LIST_LIMIT,(int)$paginator['length'])) : self::CLASS_LIST_LIMIT), |
|
151 | - 'total'=> (isset($paginator['total']) ? (int)$paginator['total'] : null) |
|
149 | + 'start'=> (isset($paginator['start']) ? max(0, (int) $paginator['start']) : 0), |
|
150 | + 'length'=> (isset($paginator['length']) ? max(1, min(self::CLASS_LIST_LIMIT, (int) $paginator['length'])) : self::CLASS_LIST_LIMIT), |
|
151 | + 'total'=> (isset($paginator['total']) ? (int) $paginator['total'] : null) |
|
152 | 152 | ]; |
153 | 153 | } |
154 | 154 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param string $version |
223 | 223 | * @return \neon\phoebe\services\adapters\common\models\PhoebeClass |
224 | 224 | */ |
225 | - protected function getClassModel($classType, $version=null) |
|
225 | + protected function getClassModel($classType, $version = null) |
|
226 | 226 | { |
227 | 227 | $query = ClassModel::find()->where([ |
228 | 228 | 'phoebe_type'=>$this->getPhoebeType(), |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | $fields = []; |
297 | 297 | $values = []; |
298 | 298 | foreach ($row as $f=>$v) { |
299 | - $fields[]=$f; |
|
299 | + $fields[] = $f; |
|
300 | 300 | $values[] = $this->pdoQuote($v); |
301 | 301 | } |
302 | 302 | if (count($fields)) |
303 | - return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(",",$values)).");"; |
|
303 | + return "REPLACE INTO `$table` (`".(implode('`,`', $fields)).'`) VALUES ('.(implode(",", $values)).");"; |
|
304 | 304 | return null; |
305 | 305 | } |
306 | 306 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @param array $fields use these to select a subset of fields returned. |
330 | 330 | * @return array the override |
331 | 331 | */ |
332 | - protected function findClassOverride($filters, $fields=[]) |
|
332 | + protected function findClassOverride($filters, $fields = []) |
|
333 | 333 | { |
334 | 334 | $selectFields = [ |
335 | 335 | 'uuid', 'label', 'selector', 'is_active', 'active_from', 'active_to', 'serialised_overrides' |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | // convert a request for overrides to serialised_overrides |
338 | 338 | if ($fields) { |
339 | 339 | if (in_array('overrides', $fields)) |
340 | - $fields[] ='serialised_overrides'; |
|
340 | + $fields[] = 'serialised_overrides'; |
|
341 | 341 | $selectFields = array_intersect($selectFields, $fields); |
342 | 342 | } |
343 | 343 | $selector = !empty($filters['selector']) ? $filters['selector'] : ''; |
@@ -83,8 +83,9 @@ discard block |
||
83 | 83 | public function __get($name) |
84 | 84 | { |
85 | 85 | $attrs = $this->getModelAttributes(); |
86 | - if (array_key_exists($name, $attrs)) |
|
87 | - return $attrs[$name]; |
|
86 | + if (array_key_exists($name, $attrs)) { |
|
87 | + return $attrs[$name]; |
|
88 | + } |
|
88 | 89 | return parent::__get($name); |
89 | 90 | } |
90 | 91 | |
@@ -92,10 +93,11 @@ discard block |
||
92 | 93 | { |
93 | 94 | $model = $this->getModel(); |
94 | 95 | $attrs = $model->attributes(); |
95 | - if (in_array($name, $attrs)) |
|
96 | - $model->$name = $value; |
|
97 | - else |
|
98 | - parent::__set($name, $value); |
|
96 | + if (in_array($name, $attrs)) { |
|
97 | + $model->$name = $value; |
|
98 | + } else { |
|
99 | + parent::__set($name, $value); |
|
100 | + } |
|
99 | 101 | } |
100 | 102 | |
101 | 103 | /** |
@@ -106,8 +108,9 @@ discard block |
||
106 | 108 | */ |
107 | 109 | protected function getPhoebeType() |
108 | 110 | { |
109 | - if (empty($this->phoebeType)) |
|
110 | - throw new \RuntimeException('The phoebeType needs to be set during construction'); |
|
111 | + if (empty($this->phoebeType)) { |
|
112 | + throw new \RuntimeException('The phoebeType needs to be set during construction'); |
|
113 | + } |
|
111 | 114 | return $this->phoebeType; |
112 | 115 | } |
113 | 116 | |
@@ -119,8 +122,9 @@ discard block |
||
119 | 122 | */ |
120 | 123 | protected function getClassType() |
121 | 124 | { |
122 | - if (empty($this->classType)) |
|
123 | - throw new \RuntimeException('The classType needs to be set during construction'); |
|
125 | + if (empty($this->classType)) { |
|
126 | + throw new \RuntimeException('The classType needs to be set during construction'); |
|
127 | + } |
|
124 | 128 | return $this->classType; |
125 | 129 | } |
126 | 130 | |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | */ |
133 | 137 | protected function getClassVersion() |
134 | 138 | { |
135 | - if (empty($this->classVersion)) |
|
136 | - throw new \RuntimeException('The classVersion needs to be set during construction'); |
|
139 | + if (empty($this->classVersion)) { |
|
140 | + throw new \RuntimeException('The classVersion needs to be set during construction'); |
|
141 | + } |
|
137 | 142 | return $this->classVersion; |
138 | 143 | } |
139 | 144 | |
@@ -172,8 +177,9 @@ discard block |
||
172 | 177 | */ |
173 | 178 | protected function getModel() |
174 | 179 | { |
175 | - if (!$this->_model) |
|
176 | - throw new \RuntimeException('The model has not yet been set'); |
|
180 | + if (!$this->_model) { |
|
181 | + throw new \RuntimeException('The model has not yet been set'); |
|
182 | + } |
|
177 | 183 | return $this->_model; |
178 | 184 | } |
179 | 185 | |
@@ -183,8 +189,9 @@ discard block |
||
183 | 189 | */ |
184 | 190 | protected function getModelAttributes() |
185 | 191 | { |
186 | - if ($this->_model) |
|
187 | - return $this->_model->attributes; |
|
192 | + if ($this->_model) { |
|
193 | + return $this->_model->attributes; |
|
194 | + } |
|
188 | 195 | return []; |
189 | 196 | } |
190 | 197 | |
@@ -197,8 +204,9 @@ discard block |
||
197 | 204 | { |
198 | 205 | $model = $this->getModel(); |
199 | 206 | $model->deleted = 1; |
200 | - if ($model->save()) |
|
201 | - return true; |
|
207 | + if ($model->save()) { |
|
208 | + return true; |
|
209 | + } |
|
202 | 210 | return $model->errors; |
203 | 211 | } |
204 | 212 | |
@@ -211,8 +219,9 @@ discard block |
||
211 | 219 | { |
212 | 220 | $model = $this->getModel(); |
213 | 221 | $model->deleted = 0; |
214 | - if ($model->save()) |
|
215 | - return true; |
|
222 | + if ($model->save()) { |
|
223 | + return true; |
|
224 | + } |
|
216 | 225 | return $model->errors; |
217 | 226 | } |
218 | 227 | |
@@ -228,10 +237,11 @@ discard block |
||
228 | 237 | 'phoebe_type'=>$this->getPhoebeType(), |
229 | 238 | 'class_type'=>$classType |
230 | 239 | ]); |
231 | - if ($version) |
|
232 | - $query->andWhere(['version'=>$version]); |
|
233 | - else |
|
234 | - $query->limit(1)->orderBy('version DESC'); |
|
240 | + if ($version) { |
|
241 | + $query->andWhere(['version'=>$version]); |
|
242 | + } else { |
|
243 | + $query->limit(1)->orderBy('version DESC'); |
|
244 | + } |
|
235 | 245 | |
236 | 246 | return $query->one(); |
237 | 247 | } |
@@ -268,8 +278,9 @@ discard block |
||
268 | 278 | ->andWhere('b.version IS NULL') |
269 | 279 | ->all(); |
270 | 280 | $classes = []; |
271 | - foreach ($models as $model) |
|
272 | - $classes[$model->class_type] = $model; |
|
281 | + foreach ($models as $model) { |
|
282 | + $classes[$model->class_type] = $model; |
|
283 | + } |
|
273 | 284 | return $classes; |
274 | 285 | } |
275 | 286 | |
@@ -291,16 +302,18 @@ discard block |
||
291 | 302 | */ |
292 | 303 | protected function getTableRowReplaceSql($table, $row) |
293 | 304 | { |
294 | - if (!is_array($row)) |
|
295 | - $row = $row->toArray(); |
|
305 | + if (!is_array($row)) { |
|
306 | + $row = $row->toArray(); |
|
307 | + } |
|
296 | 308 | $fields = []; |
297 | 309 | $values = []; |
298 | 310 | foreach ($row as $f=>$v) { |
299 | 311 | $fields[]=$f; |
300 | 312 | $values[] = $this->pdoQuote($v); |
301 | 313 | } |
302 | - if (count($fields)) |
|
303 | - return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(",",$values)).");"; |
|
314 | + if (count($fields)) { |
|
315 | + return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(",",$values)).");"; |
|
316 | + } |
|
304 | 317 | return null; |
305 | 318 | } |
306 | 319 | |
@@ -336,8 +349,9 @@ discard block |
||
336 | 349 | ]; |
337 | 350 | // convert a request for overrides to serialised_overrides |
338 | 351 | if ($fields) { |
339 | - if (in_array('overrides', $fields)) |
|
340 | - $fields[] ='serialised_overrides'; |
|
352 | + if (in_array('overrides', $fields)) { |
|
353 | + $fields[] ='serialised_overrides'; |
|
354 | + } |
|
341 | 355 | $selectFields = array_intersect($selectFields, $fields); |
342 | 356 | } |
343 | 357 | $selector = !empty($filters['selector']) ? $filters['selector'] : ''; |
@@ -366,10 +380,12 @@ discard block |
||
366 | 380 | */ |
367 | 381 | private function pdoQuote($value) |
368 | 382 | { |
369 | - if (is_array($value)) |
|
370 | - $value = json_encode($value); |
|
371 | - if (is_null($value)) |
|
372 | - return 'null'; |
|
383 | + if (is_array($value)) { |
|
384 | + $value = json_encode($value); |
|
385 | + } |
|
386 | + if (is_null($value)) { |
|
387 | + return 'null'; |
|
388 | + } |
|
373 | 389 | return neon()->db->pdo->quote($value); |
374 | 390 | } |
375 | 391 |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | public function setDataSources($sources) |
37 | 37 | { |
38 | 38 | foreach ($sources as $key=>$value) { |
39 | - if (empty($value)) |
|
40 | - unset($sources[$key]); |
|
39 | + if (empty($value)) { |
|
40 | + unset($sources[$key]); |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | $this->dataSources = $sources; |
43 | 44 | } |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | */ |
115 | 116 | protected function ddo() |
116 | 117 | { |
117 | - if ($this->_ddo == null) |
|
118 | - $this->_ddo = neon('dds')->IDdsObjectManagement; |
|
118 | + if ($this->_ddo == null) { |
|
119 | + $this->_ddo = neon('dds')->IDdsObjectManagement; |
|
120 | + } |
|
119 | 121 | return $this->_ddo; |
120 | 122 | } |
121 | 123 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function editClass($changes) |
56 | 56 | { |
57 | 57 | if (!is_array($changes)) |
58 | - throw new \RuntimeException('You should pass an array into editClass. You passed in '.print_r($changes,true)); |
|
58 | + throw new \RuntimeException('You should pass an array into editClass. You passed in '.print_r($changes, true)); |
|
59 | 59 | |
60 | 60 | // make the appropriate changes to dds. Any unknown fields are ignored |
61 | 61 | $this->dds()->editClass($this->classType, $changes); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | foreach ($fields as $k => $f) { |
74 | 74 | // map some form to Phoebe differences |
75 | - $f['link_class'] = (!empty($f['linkClass']) ? $f['linkClass'] : null); // named differently |
|
75 | + $f['link_class'] = (!empty($f['linkClass']) ? $f['linkClass'] : null); // named differently |
|
76 | 76 | // extract the definition for saving in phoebe |
77 | 77 | $definition = $f['definition']; |
78 | 78 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | // and save to phoebe - remove unallowed phoebe values for Daedalus tables |
123 | 123 | $changes = array_diff_key($changes, array_flip(['version', 'volatile', 'object_history', 'version_locked'])); |
124 | - if (count($changes)==0) |
|
124 | + if (count($changes) == 0) |
|
125 | 125 | return; |
126 | 126 | $hasChanges = parent::editClass($changes); |
127 | 127 | return $hasChanges; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | /** --------------------------------------- **/ |
162 | 162 | /** -------- Class Override Methods ------- **/ |
163 | 163 | |
164 | - public function addOverride($label, $selector='', $activeFrom=null, $activeTo=null, $isActive=true) |
|
164 | + public function addOverride($label, $selector = '', $activeFrom = null, $activeTo = null, $isActive = true) |
|
165 | 165 | { |
166 | 166 | throw new \RuntimeException("Overrides are not available for Daedalus tables"); |
167 | 167 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * reordering the form in the process |
194 | 194 | * @return array |
195 | 195 | */ |
196 | - protected function getDefinitionAsForm($excludeDeletedFields=true, array $restrictToFields=[]) |
|
196 | + protected function getDefinitionAsForm($excludeDeletedFields = true, array $restrictToFields = []) |
|
197 | 197 | { |
198 | 198 | $fields = []; |
199 | 199 | $definition = $this->definition; |
@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function editClass($changes) |
56 | 56 | { |
57 | - if (!is_array($changes)) |
|
58 | - throw new \RuntimeException('You should pass an array into editClass. You passed in '.print_r($changes,true)); |
|
57 | + if (!is_array($changes)) { |
|
58 | + throw new \RuntimeException('You should pass an array into editClass. You passed in '.print_r($changes,true)); |
|
59 | + } |
|
59 | 60 | |
60 | 61 | // make the appropriate changes to dds. Any unknown fields are ignored |
61 | 62 | $this->dds()->editClass($this->classType, $changes); |
@@ -108,10 +109,11 @@ discard block |
||
108 | 109 | if ($f['mapField'] == 1 && $currentData['map_field'] == 0) { |
109 | 110 | $this->dds()->setMemberAsMapField($this->classType, $memberRef); |
110 | 111 | } |
111 | - if ($definition['deleted'] == 1 && $currentData['deleted'] == 0) |
|
112 | - $this->dds()->deleteMember($this->classType, $memberRef); |
|
113 | - else if ($definition['deleted'] == 0 && $currentData['deleted'] == 1) |
|
114 | - $this->dds()->undeleteMember($this->classType, $memberRef); |
|
112 | + if ($definition['deleted'] == 1 && $currentData['deleted'] == 0) { |
|
113 | + $this->dds()->deleteMember($this->classType, $memberRef); |
|
114 | + } else if ($definition['deleted'] == 0 && $currentData['deleted'] == 1) { |
|
115 | + $this->dds()->undeleteMember($this->classType, $memberRef); |
|
116 | + } |
|
115 | 117 | if ($definition['deleted'] == -1) { |
116 | 118 | // remove definition from phoebe |
117 | 119 | unset($changes['definition']['fields'][$k]); |
@@ -121,8 +123,9 @@ discard block |
||
121 | 123 | |
122 | 124 | // and save to phoebe - remove unallowed phoebe values for Daedalus tables |
123 | 125 | $changes = array_diff_key($changes, array_flip(['version', 'volatile', 'object_history', 'version_locked'])); |
124 | - if (count($changes)==0) |
|
125 | - return; |
|
126 | + if (count($changes)==0) { |
|
127 | + return; |
|
128 | + } |
|
126 | 129 | $hasChanges = parent::editClass($changes); |
127 | 130 | return $hasChanges; |
128 | 131 | } |
@@ -132,8 +135,9 @@ discard block |
||
132 | 135 | */ |
133 | 136 | public function deleteClass() |
134 | 137 | { |
135 | - if (($result = parent::deleteClass())) |
|
136 | - $this->dds()->deleteClass($this->classType); |
|
138 | + if (($result = parent::deleteClass())) { |
|
139 | + $this->dds()->deleteClass($this->classType); |
|
140 | + } |
|
137 | 141 | return $result; |
138 | 142 | } |
139 | 143 | |
@@ -142,8 +146,9 @@ discard block |
||
142 | 146 | */ |
143 | 147 | public function undeleteClass() |
144 | 148 | { |
145 | - if (($result = parent::undeleteClass())) |
|
146 | - $this->dds()->undeleteClass($this->classType); |
|
149 | + if (($result = parent::undeleteClass())) { |
|
150 | + $this->dds()->undeleteClass($this->classType); |
|
151 | + } |
|
147 | 152 | return $result; |
148 | 153 | } |
149 | 154 | |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | */ |
153 | 158 | public function destroyClass() |
154 | 159 | { |
155 | - if (($result = parent::destroyClass())) |
|
156 | - $this->dds()->destroyClass($this->classType); |
|
160 | + if (($result = parent::destroyClass())) { |
|
161 | + $this->dds()->destroyClass($this->classType); |
|
162 | + } |
|
157 | 163 | return $result; |
158 | 164 | } |
159 | 165 | |
@@ -199,8 +205,9 @@ discard block |
||
199 | 205 | $definition = $this->definition; |
200 | 206 | $order = 0; |
201 | 207 | $restrictFields = count($restrictToFields) > 0; |
202 | - if ($restrictFields) |
|
203 | - $restrictFieldPostion = array_flip($restrictToFields); |
|
208 | + if ($restrictFields) { |
|
209 | + $restrictFieldPostion = array_flip($restrictToFields); |
|
210 | + } |
|
204 | 211 | if (isset($definition['fields'])) { |
205 | 212 | $fields = $definition['fields']; |
206 | 213 | foreach ($fields as $key=>$field) { |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | if (isset($field['definition'])) { |
216 | 223 | $fields[$key] = $field['definition']; |
217 | 224 | $fields[$key]['mapField'] = $field['mapField']; |
218 | - if (isset($field['deleted'])) |
|
219 | - $fields[$key]['deleted'] = $field['deleted']; |
|
225 | + if (isset($field['deleted'])) { |
|
226 | + $fields[$key]['deleted'] = $field['deleted']; |
|
227 | + } |
|
220 | 228 | // TODO - 20180522 NJ |
221 | 229 | // THIS WILL GO WRONG WITH DELETED FIELDS WHERE FINAL SUBMIT BUTTON MAY BE IN WRONG PLACE |
222 | 230 | $fields[$key]['order'] = ($restrictFields ? ($restrictFieldPostion[$key]) : $order++); |
@@ -232,8 +240,9 @@ discard block |
||
232 | 240 | protected $_dds = null; |
233 | 241 | protected function dds() |
234 | 242 | { |
235 | - if ($this->_dds == null) |
|
236 | - $this->_dds = neon('dds')->iDdsClassManagement; |
|
243 | + if ($this->_dds == null) { |
|
244 | + $this->_dds = neon('dds')->iDdsClassManagement; |
|
245 | + } |
|
237 | 246 | return $this->_dds; |
238 | 247 | } |
239 | 248 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * Set this up as a daedalus type |
48 | 48 | * @param array $config |
49 | 49 | */ |
50 | - public function __construct($config=[]) |
|
50 | + public function __construct($config = []) |
|
51 | 51 | { |
52 | 52 | $path = '\neon\phoebe\services\adapters\daedalus'; |
53 | 53 | $config['phoebeType'] = 'daedalus'; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | /** ------------ Class Methods ----------- **/ |
96 | 96 | |
97 | - public function listClasses(&$paginator=[], $filters=[], $orderBy=[], $includeDeleted=false) |
|
97 | + public function listClasses(&$paginator = [], $filters = [], $orderBy = [], $includeDeleted = false) |
|
98 | 98 | { |
99 | 99 | $classes = parent::listClasses($paginator, $filters, $orderBy, $includeDeleted); |
100 | 100 | $this->mergeDaedalusFields($classes); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @inheritdoc |
106 | 106 | */ |
107 | - public function addClass(&$classType, $module='') |
|
107 | + public function addClass(&$classType, $module = '') |
|
108 | 108 | { |
109 | 109 | $classType = $this->canonicaliseRef($classType); |
110 | 110 | $class = parent::addClass($classType, $module); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * @inheritdoc |
129 | 129 | */ |
130 | - public function listObjects($classType, &$paginator=[], $filters=[], $orderBy=[], $additionalFields=[]) |
|
130 | + public function listObjects($classType, &$paginator = [], $filters = [], $orderBy = [], $additionalFields = []) |
|
131 | 131 | { |
132 | 132 | $filters = null; |
133 | 133 | // get our data directly from daedalus - objects are not stored in phoebe |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @inheritdoc |
151 | 151 | */ |
152 | - public function addObject($classType, $overrideCriteria=[]) |
|
152 | + public function addObject($classType, $overrideCriteria = []) |
|
153 | 153 | { |
154 | 154 | // Daedalus doesn't manage overrides currently |
155 | 155 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $classes[$ct]['count_current'] = 0; |
210 | 210 | $classTypes[] = $ct; |
211 | 211 | } |
212 | - $query = "SELECT * FROM dds_class WHERE `class_type` IN ('".implode("','",$classTypes)."')"; |
|
212 | + $query = "SELECT * FROM dds_class WHERE `class_type` IN ('".implode("','", $classTypes)."')"; |
|
213 | 213 | $counts = neon()->db->createCommand($query)->queryAll(); |
214 | 214 | foreach ($counts as $c) { |
215 | 215 | $classes[$c['class_type']] = array_merge($classes[$c['class_type']], $c); |
@@ -65,8 +65,9 @@ discard block |
||
65 | 65 | $class = $this->canonicaliseRef($class); |
66 | 66 | |
67 | 67 | // descriptions of a class are stored as hints in the form |
68 | - if (isset($definition['description'])) |
|
69 | - $definition['hint'] = $definition['description']; |
|
68 | + if (isset($definition['description'])) { |
|
69 | + $definition['hint'] = $definition['description']; |
|
70 | + } |
|
70 | 71 | |
71 | 72 | // pass the definition to a form object and then get back the full definition |
72 | 73 | $definition['name'] = $class; |
@@ -78,8 +79,9 @@ discard block |
||
78 | 79 | |
79 | 80 | // save the class information |
80 | 81 | $phoebeClass = $this->getClass($class); |
81 | - if (!$phoebeClass) |
|
82 | - $phoebeClass = $this->addClass($class, $module); |
|
82 | + if (!$phoebeClass) { |
|
83 | + $phoebeClass = $this->addClass($class, $module); |
|
84 | + } |
|
83 | 85 | $phoebeClass->editClass($classDefinition); |
84 | 86 | |
85 | 87 | // close the migration |
@@ -159,8 +161,9 @@ discard block |
||
159 | 161 | $ddsObject = $this->ddo()->getObject($objectId); |
160 | 162 | |
161 | 163 | $object = $objectId ? $this->createFauxIPhoebeObject($classType, $objectId, $ddsObject) : null; |
162 | - if ($object) |
|
163 | - $object->changeLogUuid = $changeLogUuid; |
|
164 | + if ($object) { |
|
165 | + $object->changeLogUuid = $changeLogUuid; |
|
166 | + } |
|
164 | 167 | return $object; |
165 | 168 | } |
166 | 169 | |
@@ -221,16 +224,18 @@ discard block |
||
221 | 224 | protected $_dds = null; |
222 | 225 | protected function dds() |
223 | 226 | { |
224 | - if ($this->_dds == null) |
|
225 | - $this->_dds = neon('dds')->IDdsClassManagement; |
|
227 | + if ($this->_dds == null) { |
|
228 | + $this->_dds = neon('dds')->IDdsClassManagement; |
|
229 | + } |
|
226 | 230 | return $this->_dds; |
227 | 231 | } |
228 | 232 | |
229 | 233 | protected $_ddo = null; |
230 | 234 | protected function ddo() |
231 | 235 | { |
232 | - if ($this->_ddo == null) |
|
233 | - $this->_ddo = neon('dds')->IDdsObjectManagement; |
|
236 | + if ($this->_ddo == null) { |
|
237 | + $this->_ddo = neon('dds')->IDdsObjectManagement; |
|
238 | + } |
|
234 | 239 | return $this->_ddo; |
235 | 240 | } |
236 | 241 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * @inheritdoc |
20 | 20 | */ |
21 | - public function getClassFormDefinition(array $fields=[]) |
|
21 | + public function getClassFormDefinition(array $fields = []) |
|
22 | 22 | { |
23 | 23 | return []; |
24 | 24 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | class PhoebeType extends PhoebeTypeBase |
16 | 16 | { |
17 | - public function __construct($config=[]) |
|
17 | + public function __construct($config = []) |
|
18 | 18 | { |
19 | 19 | $path = '\neon\phoebe\services\adapters\basic'; |
20 | 20 | $config['phoebeType'] = 'basic'; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $appForm = 'applicationForm'; |
107 | 107 | // process the parameters |
108 | 108 | if (!isset($params['classType'])) |
109 | - throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params,true)); |
|
109 | + throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params, true)); |
|
110 | 110 | $classType = $params['classType']; |
111 | 111 | $uuid = !empty($params['uuid']) ? $params['uuid'] : null; |
112 | 112 | $id = !empty($params['id']) ? $params['id'] : null; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $assignForm = !empty($params['assignForm']) ? $params['assignForm'] : 'form'; |
119 | 119 | $assignSubmitted = !empty($params['assignSubmitted']) ? $params['assignSubmitted'] : 'submitted'; |
120 | 120 | $dataSources = !empty($params['dataSources']) ? $params['dataSources'] : []; |
121 | - $readOnly = isset($params['readOnly']) ? (bool)$params['readOnly'] : false; |
|
122 | - $printOnly = isset($params['printOnly']) ? (bool)$params['printOnly'] : false; |
|
123 | - $enableAjaxValidation = isset($params['enableAjaxValidation']) ? (bool)$params['enableAjaxValidation'] : true; |
|
124 | - $enableAjaxSubmission = isset($params['enableAjaxSubmission']) ? (bool)$params['enableAjaxSubmission'] : false; |
|
121 | + $readOnly = isset($params['readOnly']) ? (bool) $params['readOnly'] : false; |
|
122 | + $printOnly = isset($params['printOnly']) ? (bool) $params['printOnly'] : false; |
|
123 | + $enableAjaxValidation = isset($params['enableAjaxValidation']) ? (bool) $params['enableAjaxValidation'] : true; |
|
124 | + $enableAjaxSubmission = isset($params['enableAjaxSubmission']) ? (bool) $params['enableAjaxSubmission'] : false; |
|
125 | 125 | $ajaxValidationUrl = !empty($params['ajaxValidationUrl']) ? $params['ajaxValidationUrl'] : '/phoebe/appforms/index/validate-form'; |
126 | 126 | $initialiseFromDds = !empty($params['initialiseFromDds']) ? $params['initialiseFromDds'] : null; |
127 | 127 | //$mapFilters = !empty($params['mapFilters']) ? $params['mapFilters'] : []; |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | $requiredDataSources = array_keys($class->getRequiredDataSources()); |
142 | 142 | $missingDataSources = array_diff($requiredDataSources, array_keys($dataSources)); |
143 | 143 | if (count($missingDataSources)) { |
144 | - throw new \RuntimeException('Error - you need to provide uuids for the following classes: '.implode(', ',$missingDataSources)); |
|
144 | + throw new \RuntimeException('Error - you need to provide uuids for the following classes: '.implode(', ', $missingDataSources)); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // prefix invalid (HTML5) ids with a letter |
148 | 148 | $id = ($id ? $id : ($uuid ? $uuid : null)); |
149 | 149 | if ($id) { |
150 | 150 | if (is_numeric($id[0]) || $id[0] == '-' || $id[0] == '_') |
151 | - $id = 'z' . $id; |
|
151 | + $id = 'z'.$id; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // get hold of the form definition |
@@ -105,8 +105,9 @@ discard block |
||
105 | 105 | |
106 | 106 | $appForm = 'applicationForm'; |
107 | 107 | // process the parameters |
108 | - if (!isset($params['classType'])) |
|
109 | - throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params,true)); |
|
108 | + if (!isset($params['classType'])) { |
|
109 | + throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params,true)); |
|
110 | + } |
|
110 | 111 | $classType = $params['classType']; |
111 | 112 | $uuid = !empty($params['uuid']) ? $params['uuid'] : null; |
112 | 113 | $id = !empty($params['id']) ? $params['id'] : null; |
@@ -135,8 +136,9 @@ discard block |
||
135 | 136 | $class = $phoebe->getClass($classType); |
136 | 137 | $appFormClasses[$classType] = $class; |
137 | 138 | } |
138 | - if (!$class) |
|
139 | - throw new \RuntimeException('Error - cannot get hold of the form class '.$classType); |
|
139 | + if (!$class) { |
|
140 | + throw new \RuntimeException('Error - cannot get hold of the form class '.$classType); |
|
141 | + } |
|
140 | 142 | |
141 | 143 | $requiredDataSources = array_keys($class->getRequiredDataSources()); |
142 | 144 | $missingDataSources = array_diff($requiredDataSources, array_keys($dataSources)); |
@@ -147,8 +149,9 @@ discard block |
||
147 | 149 | // prefix invalid (HTML5) ids with a letter |
148 | 150 | $id = ($id ? $id : ($uuid ? $uuid : null)); |
149 | 151 | if ($id) { |
150 | - if (is_numeric($id[0]) || $id[0] == '-' || $id[0] == '_') |
|
151 | - $id = 'z' . $id; |
|
152 | + if (is_numeric($id[0]) || $id[0] == '-' || $id[0] == '_') { |
|
153 | + $id = 'z' . $id; |
|
154 | + } |
|
152 | 155 | } |
153 | 156 | |
154 | 157 | // get hold of the form definition |
@@ -185,8 +188,9 @@ discard block |
||
185 | 188 | } else if ($uuid) { |
186 | 189 | $phoebe = neon('phoebe')->getIPhoebeType($appForm); |
187 | 190 | $object = $phoebe->getObject($uuid); |
188 | - if (!$object) |
|
189 | - throw new \yii\web\NotFoundHttpException('The requested form was not found. Uuid='.$uuid); |
|
191 | + if (!$object) { |
|
192 | + throw new \yii\web\NotFoundHttpException('The requested form was not found. Uuid='.$uuid); |
|
193 | + } |
|
190 | 194 | $appFormObjects[$uuid] = $object; |
191 | 195 | } |
192 | 196 | $template->assign($assignSubmitted, false); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * Start the appForm Builder for this class |
63 | 63 | * @param string $type the class type of the object required |
64 | 64 | */ |
65 | - public function actionEdit($type=null) |
|
65 | + public function actionEdit($type = null) |
|
66 | 66 | { |
67 | 67 | if (!$this->canDevelop()) |
68 | 68 | throw new \HttpException(403, 'This operation is not permitted here'); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $grid = new \neon\core\grid\PhoebeGrid([ |
123 | 123 | 'phoebeType'=>$this->phoebeType, |
124 | 124 | 'classType'=>$type, |
125 | - 'additionalColumns' => ['data','deleted'] |
|
125 | + 'additionalColumns' => ['data', 'deleted'] |
|
126 | 126 | ]); |
127 | 127 | return $this->render('list', [ |
128 | 128 | 'grid' => $grid, |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $type the applicationForm class type the object belongs to |
138 | 138 | * @param string $id the Object id |
139 | 139 | */ |
140 | - public function actionDeleteObject($type, $id, $redirect=true) |
|
140 | + public function actionDeleteObject($type, $id, $redirect = true) |
|
141 | 141 | { |
142 | 142 | $this->deleteObject($id); |
143 | 143 | if ($redirect) |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param type $classType |
151 | 151 | * @return type |
152 | 152 | */ |
153 | - public function actionValidateForm($classType, $name=null) |
|
153 | + public function actionValidateForm($classType, $name = null) |
|
154 | 154 | { |
155 | 155 | return PhoebeValidator::validateForm('applicationForm', $classType, $name); |
156 | 156 | } |
@@ -64,8 +64,9 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function actionEdit($type=null) |
66 | 66 | { |
67 | - if (!$this->canDevelop()) |
|
68 | - throw new \HttpException(403, 'This operation is not permitted here'); |
|
67 | + if (!$this->canDevelop()) { |
|
68 | + throw new \HttpException(403, 'This operation is not permitted here'); |
|
69 | + } |
|
69 | 70 | |
70 | 71 | $builderDefinition = $this->getBuilderDefinition($type); |
71 | 72 | $isNew = ($type === null || count($builderDefinition) == 0); |
@@ -140,8 +141,9 @@ discard block |
||
140 | 141 | public function actionDeleteObject($type, $id, $redirect=true) |
141 | 142 | { |
142 | 143 | $this->deleteObject($id); |
143 | - if ($redirect) |
|
144 | - $this->redirect([$this->baseUrl.'list-objects', 'type' => $type]); |
|
144 | + if ($redirect) { |
|
145 | + $this->redirect([$this->baseUrl.'list-objects', 'type' => $type]); |
|
146 | + } |
|
145 | 147 | return ''; |
146 | 148 | } |
147 | 149 | |
@@ -188,11 +190,13 @@ discard block |
||
188 | 190 | public function actionEditObject($type, $id) |
189 | 191 | { |
190 | 192 | $form = $this->getPhoebeForm($type); |
191 | - if (neon()->request->getIsAjax()) |
|
192 | - return $form->ajaxValidation(); |
|
193 | + if (neon()->request->getIsAjax()) { |
|
194 | + return $form->ajaxValidation(); |
|
195 | + } |
|
193 | 196 | $object = $this->getObject($id); |
194 | - if (!$object) |
|
195 | - throw new NotFoundHttpException('The requested form was not found'); |
|
197 | + if (!$object) { |
|
198 | + throw new NotFoundHttpException('The requested form was not found'); |
|
199 | + } |
|
196 | 200 | if ($form->processRequest()) { |
197 | 201 | $object->editObject($form->getData()); |
198 | 202 | $this->redirect([$this->baseUrl.'list-objects', 'type'=>$type]); |