Passed
Push — releases ( 51c2cc...e1d10c )
by steve
39:06 queued 13:38
created
neon/daedalus/services/ddsManager/DdsObjectMapManager.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * requests to the database within one call
23 23
 	 * @var array
24 24
 	 */
25
-	private static $_mapResultsCache=[];
25
+	private static $_mapResultsCache = [];
26 26
 	/**
27 27
 	 * The set of map requests
28 28
 	 * An array with the requests and the maximum number in the chain
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @inheritdoc
47 47
 	 */
48
-	public function getObjectMap($classType, $filters=[], $fields=[], $start=0, $length=1000, $includeDeleted=false)
48
+	public function getObjectMap($classType, $filters = [], $fields = [], $start = 0, $length = 1000, $includeDeleted = false)
49 49
 	{
50 50
 		if (!$classType)
51 51
 			throw new \InvalidArgumentException("Invalid classType '$classType' in getObjectMap. Correct calling code");
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$cacheKey = md5(serialize(func_get_args()));
54 54
 		if (empty(self::$_mapResultsCache[$cacheKey])) {
55 55
 			try {
56
-				$limit = ['start' => max(0, (integer)$start), 'length' => min(1000, (integer)$length)];
56
+				$limit = ['start' => max(0, (integer) $start), 'length' => min(1000, (integer) $length)];
57 57
 				$classType = $this->canonicaliseRef($classType);
58 58
 				$fieldsClause = '';
59 59
 				$linkJoins = [];
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 				$filterClause = '';
110 110
 				$filterValues = [];
111 111
 				if ($filters) {
112
-					$ddsObjectFields = ['_uuid','_created','_deleted','_updated'];
112
+					$ddsObjectFields = ['_uuid', '_created', '_deleted', '_updated'];
113 113
 					// whitelist filter keys to prevent sql injection
114 114
 					$members = $this->getClassMembers($classType);
115 115
 					$filterSubClause = [];
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 							$filterValues[":$field$vcount"] = $v;
132 132
 							$vcount++;
133 133
 						}
134
-						$inClause = implode(',',$inClause);
134
+						$inClause = implode(',', $inClause);
135 135
 						if (!empty($members[$field]) && $members[$field]['data_type_ref'] == 'link_multi') {
136 136
 							$linkName = "link$field";
137 137
 							if (!isset($linkJoins[$linkName]))
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
 							$filterSubClause[] = "AND $keyClause IN ($inClause)";
142 142
 						}
143 143
 					}
144
-					$filterClause = implode (' ', $filterSubClause);
144
+					$filterClause = implode(' ', $filterSubClause);
145 145
 				}
146 146
 				$linkJoinsClause = implode(' ', $linkJoins);
147 147
 
148
-				$query = "SELECT DISTINCT `o`.`_uuid`, $fieldsClause FROM `dds_object` `o` LEFT JOIN  `$table` `t` ON `o`.`_uuid`=`t`.`_uuid` " .
149
-					"$linkJoinsClause WHERE `o`.`_class_type` = '$classType' $filterClause $notDeleted ORDER BY $fieldsClause " .
148
+				$query = "SELECT DISTINCT `o`.`_uuid`, $fieldsClause FROM `dds_object` `o` LEFT JOIN  `$table` `t` ON `o`.`_uuid`=`t`.`_uuid` ".
149
+					"$linkJoinsClause WHERE `o`.`_class_type` = '$classType' $filterClause $notDeleted ORDER BY $fieldsClause ".
150 150
 					"LIMIT $limit[start], $limit[length]";
151 151
 				$command = neon()->db->createCommand($query);
152 152
 				if ($filters)
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 					unset($r['_uuid']);
159 159
 
160 160
 					// set the map
161
-					$map[$uuid] = (count($fields)==1) ? current($r) : $r;
161
+					$map[$uuid] = (count($fields) == 1) ? current($r) : $r;
162 162
 				}
163 163
 				self::$_mapResultsCache[$cacheKey] = $map;
164 164
 			} catch (\Exception $e) {
165 165
 				$errorMessage = "Exception during getting a map. This may be caused by empty filters - you cannot filter on null. ".
166
-					"Your filters were: ".print_r($filters,true).". The error message is ".$e->getMessage();
166
+					"Your filters were: ".print_r($filters, true).". The error message is ".$e->getMessage();
167 167
 				\Neon::error($errorMessage, 'DDS');
168 168
 				debug_message($errorMessage);
169 169
 				return [];
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	/**
176 176
 	 * @inheritdoc
177 177
 	 */
178
-	public function makeMapLookupRequest($objectUuids, $chainMapFields=[], $classType=null)
178
+	public function makeMapLookupRequest($objectUuids, $chainMapFields = [], $classType = null)
179 179
 	{
180 180
 		if (empty($objectUuids))
181 181
 			return null;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		foreach ($linkedMembers as $lm) {
199 199
 			$requestKeys[] = $this->makeMapChainLookupRequest($objectUuids, [$lm]);
200 200
 		}
201
-		return implode('|',$requestKeys);
201
+		return implode('|', $requestKeys);
202 202
 	}
203 203
 
204 204
 	/**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			foreach ($partials[0] as $u=>$p) {
218 218
 				foreach ($p as $i=>$v) {
219 219
 					if ($this->isUuid($v)) {
220
-						for ($i=1; $i<count($requestKeys); $i++) {
220
+						for ($i = 1; $i < count($requestKeys); $i++) {
221 221
 							if (array_key_exists($v, $partials[$i][1])) {
222 222
 								$partials[0][$u][$i] = $partials[$i][1][$v];
223 223
 								continue;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	/**
234 234
 	 * @inheritdoc
235 235
 	 */
236
-	public function makeMapChainLookupRequest($objectUuids, $chainMembers=[], $chainMapFields=[], $inReverse=false)
236
+	public function makeMapChainLookupRequest($objectUuids, $chainMembers = [], $chainMapFields = [], $inReverse = false)
237 237
 	{
238 238
 		if (empty($objectUuids))
239 239
 			return null;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			$this->getMapLookupByLevel($chain);
274 274
 			foreach ($chain as $k=>$r) {
275 275
 				if ($r['next_uuid'])
276
-					$requests['chains'][($i+1)][$k]['uuid'] = $r['next_uuid'];
276
+					$requests['chains'][($i + 1)][$k]['uuid'] = $r['next_uuid'];
277 277
 			}
278 278
 		}
279 279
 		$this->convertMapRequestResults();
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			$requestsByUuid[$r['uuid']][] = $r;
333 333
 		}
334 334
 		$objectRows = DdsObject::find()
335
-			->select(['_uuid','_class_type'])
335
+			->select(['_uuid', '_class_type'])
336 336
 			->where(['_uuid'=>$endpoints])
337 337
 			->andWhere(['_deleted'=>0])
338 338
 			->asArray()
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
 			// now find all the maps members for the required classes
354 354
 			$mapFields = DdsMember::find()
355
-				->select(['class_type','member_ref'])
355
+				->select(['class_type', 'member_ref'])
356 356
 				->where(['class_type'=>$classTypes, 'deleted'=>0, 'map_field'=>1])
357 357
 				->asArray()
358 358
 				->all();
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 			foreach ($objectsByClassMapsAndChain as $class => $chainMapObjects) {
369 369
 				foreach ($chainMapObjects as $chain => $mapObjects) {
370 370
 					foreach ($mapObjects as $mapField => $objectUuids) {
371
-						$objs = "'".implode("','",$objectUuids)."'";
371
+						$objs = "'".implode("','", $objectUuids)."'";
372 372
 						// make sure a map field can be created
373 373
 						$mapFieldsClause = '';
374 374
 						if ($mapField === self::$_defaultMapChain) {
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 							$mapFieldsClause = "CAST(`$mapsByClass[$class]` AS CHAR)";
378 378
 						} else {
379 379
 							$mapFieldsClause = "CONCAT_WS('$hackySeparator'";
380
-							foreach (explode(',',$mapField) as $m) {
380
+							foreach (explode(',', $mapField) as $m) {
381 381
 								$mapFieldsClause .= ",CAST(`$m` AS CHAR)";
382 382
 							}
383 383
 							$mapFieldsClause .= ')';
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		$mapsByChainAndUuid = [];
403 403
 		foreach ($maps as $m) {
404 404
 			if (strpos($m['map'], $hackySeparator) !== false) {
405
-				$m['map'] = explode($hackySeparator,$m['map']);
405
+				$m['map'] = explode($hackySeparator, $m['map']);
406 406
 			}
407 407
 			$mapsByChainAndUuid[$m['chain']][$m['mapFields']][$m['uuid']] = $m;
408 408
 		}
@@ -473,14 +473,14 @@  discard block
 block discarded – undo
473 473
 		$chainCount = count($chainMembers);
474 474
 		// split the chain up into requests per chain level if there are any
475 475
 		foreach ($chainMembers as $i=>$mc) {
476
-			$mapFieldKey = ($i == 0 ? 0 : $chainMembers[$i-1]);
477
-			$mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',',$chainMapFields[$mapFieldKey]) : self::$_defaultMapChain;
478
-			$requests['chains'][$i][$requestKey] = ['uuid'=>($i===0?$objectUuid:null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>$mc, 'key'=>$requestKey];
476
+			$mapFieldKey = ($i == 0 ? 0 : $chainMembers[$i - 1]);
477
+			$mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',', $chainMapFields[$mapFieldKey]) : self::$_defaultMapChain;
478
+			$requests['chains'][$i][$requestKey] = ['uuid'=>($i === 0 ? $objectUuid : null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>$mc, 'key'=>$requestKey];
479 479
 		}
480 480
 		// add a final chain for the last item
481
-		$mapFieldKey = ($chainCount == 0 ? 0 : $chainMembers[$chainCount-1]);
482
-		$mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',',$chainMapFields[$mapFieldKey]) : self::$_defaultMapChain;
483
-		$requests['chains'][$chainCount][$requestKey] = ['uuid'=>($chainCount===0?$objectUuid:null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>'__FINAL__', 'key'=>$requestKey];
481
+		$mapFieldKey = ($chainCount == 0 ? 0 : $chainMembers[$chainCount - 1]);
482
+		$mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',', $chainMapFields[$mapFieldKey]) : self::$_defaultMapChain;
483
+		$requests['chains'][$chainCount][$requestKey] = ['uuid'=>($chainCount === 0 ? $objectUuid : null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>'__FINAL__', 'key'=>$requestKey];
484 484
 
485 485
 		// and add the requestKey so we don't calculate this again
486 486
 		$requests['keys'][$requestKey] = [
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		$results = &static::$_mapResults;
510 510
 
511 511
 		$tempResults = [];
512
-		if (count($chains)===0)
512
+		if (count($chains) === 0)
513 513
 			return;
514 514
 		foreach ($chains as $level => $maps) {
515 515
 			foreach ($maps as $key=>$map) {
Please login to merge, or discard this patch.
Braces   +51 added lines, -35 removed lines patch added patch discarded remove patch
@@ -47,8 +47,9 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function getObjectMap($classType, $filters=[], $fields=[], $start=0, $length=1000, $includeDeleted=false)
49 49
 	{
50
-		if (!$classType)
51
-			throw new \InvalidArgumentException("Invalid classType '$classType' in getObjectMap. Correct calling code");
50
+		if (!$classType) {
51
+					throw new \InvalidArgumentException("Invalid classType '$classType' in getObjectMap. Correct calling code");
52
+		}
52 53
 
53 54
 		$cacheKey = md5(serialize(func_get_args()));
54 55
 		if (empty(self::$_mapResultsCache[$cacheKey])) {
@@ -73,8 +74,9 @@  discard block
 block discarded – undo
73 74
 						$class2Member = Arr::index($linkedMemberClasses, 'class_type');
74 75
 						foreach ($linkedMembers as $lm) {
75 76
 							// only try to link through to tables that are within daedalus
76
-							if (isset($class2Member[$lm['link_class']]))
77
-								$field2link[$lm['member_ref']] = $class2Member[$lm['link_class']];
77
+							if (isset($class2Member[$lm['link_class']])) {
78
+															$field2link[$lm['member_ref']] = $class2Member[$lm['link_class']];
79
+							}
78 80
 						}
79 81
 					}
80 82
 					foreach ($fields as $field) {
@@ -82,9 +84,9 @@  discard block
 block discarded – undo
82 84
 							$fl = $field2link[$field];
83 85
 							$table = $this->getTableFromClassType($fl['class_type']);
84 86
 							$getFields[] = "`$table`.`$fl[member_ref]`";
85
-							if ($linkedMembers[$field]['data_type_ref'] == 'link_uni')
86
-								$linkJoins[$table] = "LEFT JOIN `$table` ON `t`.`$field`=`$table`.`_uuid`";
87
-							else {
87
+							if ($linkedMembers[$field]['data_type_ref'] == 'link_uni') {
88
+															$linkJoins[$table] = "LEFT JOIN `$table` ON `t`.`$field`=`$table`.`_uuid`";
89
+							} else {
88 90
 								$linkName = 'link'.$field;
89 91
 								$linkJoins[$linkName] = "LEFT JOIN `dds_link` `$linkName` ON (`o`.`_uuid`=`$linkName`.`from_id` AND `$linkName`.`from_member`='$field')";
90 92
 								$linkJoins[$table] = "LEFT JOIN `$table` ON `$linkName`.`to_id` =`$table`.`_uuid`";
@@ -96,8 +98,9 @@  discard block
 block discarded – undo
96 98
 					$fieldsClause = implode(', ', $getFields);
97 99
 				} else {
98 100
 					$member = $this->getMapMemberForClass($classType);
99
-					if (!$member)
100
-						throw new \RuntimeException("There is no mappable member field set on class $classType");
101
+					if (!$member) {
102
+											throw new \RuntimeException("There is no mappable member field set on class $classType");
103
+					}
101 104
 					// set this as an array for later
102 105
 					$fields = [$member['member_ref']];
103 106
 					$fieldsClause = "`t`.`$member[member_ref]`";
@@ -116,12 +119,14 @@  discard block
 block discarded – undo
116 119
 					foreach ($filters as $field=>$value) {
117 120
 						if ($field == '_map_field_') {
118 121
 							$mapMember = $this->getMapMemberForClass($classType);
119
-							if ($mapMember && $value)
120
-								$filterSubClause[] = "AND `t`.`$mapMember[member_ref]` LIKE '%$value%'";
122
+							if ($mapMember && $value) {
123
+															$filterSubClause[] = "AND `t`.`$mapMember[member_ref]` LIKE '%$value%'";
124
+							}
121 125
 							continue;
122 126
 						}
123
-						if (!(isset($members[$field]) || in_array($field, $ddsObjectFields)))
124
-							continue;
127
+						if (!(isset($members[$field]) || in_array($field, $ddsObjectFields))) {
128
+													continue;
129
+						}
125 130
 						$keyClause = (in_array($field, $ddsObjectFields)) ? "`o`.`$field`" : "`t`.`$field`";
126 131
 						$value = is_array($value) ? $value : [$value];
127 132
 						$vcount = 1;
@@ -134,8 +139,9 @@  discard block
 block discarded – undo
134 139
 						$inClause = implode(',',$inClause);
135 140
 						if (!empty($members[$field]) && $members[$field]['data_type_ref'] == 'link_multi') {
136 141
 							$linkName = "link$field";
137
-							if (!isset($linkJoins[$linkName]))
138
-								$linkJoins[$linkName] = "LEFT JOIN `dds_link` `$linkName` ON (`o`.`_uuid`=`$linkName`.`from_id` AND `$linkName`.`from_member`='$field')";
142
+							if (!isset($linkJoins[$linkName])) {
143
+															$linkJoins[$linkName] = "LEFT JOIN `dds_link` `$linkName` ON (`o`.`_uuid`=`$linkName`.`from_id` AND `$linkName`.`from_member`='$field')";
144
+							}
139 145
 							$filterSubClause[] = "AND `$linkName`.`to_id` IN ($inClause)";
140 146
 						} else {
141 147
 							$filterSubClause[] = "AND $keyClause IN ($inClause)";
@@ -149,8 +155,9 @@  discard block
 block discarded – undo
149 155
 					"$linkJoinsClause WHERE `o`.`_class_type` = '$classType' $filterClause $notDeleted ORDER BY $fieldsClause " .
150 156
 					"LIMIT $limit[start], $limit[length]";
151 157
 				$command = neon()->db->createCommand($query);
152
-				if ($filters)
153
-					$command->bindValues($filterValues);
158
+				if ($filters) {
159
+									$command->bindValues($filterValues);
160
+				}
154 161
 				$rows = $command->queryAll();
155 162
 				foreach ($rows as $r) {
156 163
 					// extract out the uuid result
@@ -177,8 +184,9 @@  discard block
 block discarded – undo
177 184
 	 */
178 185
 	public function makeMapLookupRequest($objectUuids, $chainMapFields=[], $classType=null)
179 186
 	{
180
-		if (empty($objectUuids))
181
-			return null;
187
+		if (empty($objectUuids)) {
188
+					return null;
189
+		}
182 190
 		/*  See if there are any linked fields that we need to get
183 191
 			The implementation here is somewhat crude. Generally speaking we are probably looking
184 192
 			at needing to implement graphql or something similar to easily manage all the possible
@@ -235,8 +243,9 @@  discard block
 block discarded – undo
235 243
 	 */
236 244
 	public function makeMapChainLookupRequest($objectUuids, $chainMembers=[], $chainMapFields=[], $inReverse=false)
237 245
 	{
238
-		if (empty($objectUuids))
239
-			return null;
246
+		if (empty($objectUuids)) {
247
+					return null;
248
+		}
240 249
 
241 250
 		// create a request key based on the input parameters
242 251
 		$requestKey = md5(serialize(func_get_args()));
@@ -265,15 +274,17 @@  discard block
 block discarded – undo
265 274
 	{
266 275
 		$requests = &static::$_mapRequests;
267 276
 		// check we have any requests to make
268
-		if (count($requests['chains']) === 0)
269
-			return;
277
+		if (count($requests['chains']) === 0) {
278
+					return;
279
+		}
270 280
 		// run through the chain and get the reverse maps for each level of requests
271 281
 		foreach ($requests['chains'] as $i=>&$chain) {
272 282
 			// the requests will be filled in during this call
273 283
 			$this->getMapLookupByLevel($chain);
274 284
 			foreach ($chain as $k=>$r) {
275
-				if ($r['next_uuid'])
276
-					$requests['chains'][($i+1)][$k]['uuid'] = $r['next_uuid'];
285
+				if ($r['next_uuid']) {
286
+									$requests['chains'][($i+1)][$k]['uuid'] = $r['next_uuid'];
287
+				}
277 288
 			}
278 289
 		}
279 290
 		$this->convertMapRequestResults();
@@ -322,8 +333,9 @@  discard block
 block discarded – undo
322 333
 	 */
323 334
 	private function getMapLookupByLevel(&$requests)
324 335
 	{
325
-		if (empty($requests))
326
-			return;
336
+		if (empty($requests)) {
337
+					return;
338
+		}
327 339
 
328 340
 		$endpoints = [];
329 341
 		$requestsByUuid = [];
@@ -372,8 +384,9 @@  discard block
 block discarded – undo
372 384
 						// make sure a map field can be created
373 385
 						$mapFieldsClause = '';
374 386
 						if ($mapField === self::$_defaultMapChain) {
375
-							if (!isset($mapsByClass[$class]))
376
-								continue;
387
+							if (!isset($mapsByClass[$class])) {
388
+															continue;
389
+							}
377 390
 							$mapFieldsClause = "CAST(`$mapsByClass[$class]` AS CHAR)";
378 391
 						} else {
379 392
 							$mapFieldsClause = "CONCAT_WS('$hackySeparator'";
@@ -436,8 +449,9 @@  discard block
 block discarded – undo
436 449
 	 */
437 450
 	private function addRequest($requestKey, $objectUuid, $chainMembers, $chainMapFields, $inReverse)
438 451
 	{
439
-		if (empty($objectUuid))
440
-			return;
452
+		if (empty($objectUuid)) {
453
+					return;
454
+		}
441 455
 
442 456
 		// Treat a request for objectUuids as multiple single object map requests
443 457
 		// TODO NJ 20190415 - make this work properly with multiple uuids without needing multiple requests
@@ -466,8 +480,9 @@  discard block
 block discarded – undo
466 480
 		$requests = &static::$_mapRequests; // to make the code slightly shorter
467 481
 
468 482
 		// check to see if the request has already added
469
-		if (isset($requests['keys'][$requestKey]))
470
-			return;
483
+		if (isset($requests['keys'][$requestKey])) {
484
+					return;
485
+		}
471 486
 
472 487
 		// calculate how many chains we are going down
473 488
 		$chainCount = count($chainMembers);
@@ -509,8 +524,9 @@  discard block
 block discarded – undo
509 524
 		$results = &static::$_mapResults;
510 525
 
511 526
 		$tempResults = [];
512
-		if (count($chains)===0)
513
-			return;
527
+		if (count($chains)===0) {
528
+					return;
529
+		}
514 530
 		foreach ($chains as $level => $maps) {
515 531
 			foreach ($maps as $key=>$map) {
516 532
 				$tempResults[$key][$level][$map['uuid']] = $map['map'];
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/DdsObjectManager.php 2 patches
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 	 * requests to the database within one call
32 32
 	 * @var array
33 33
 	 */
34
-	private static $_requestResultsCache=[];
35
-	private static $_linkResultsCache=[];
36
-	private static $_mapResultsCache=[];
34
+	private static $_requestResultsCache = [];
35
+	private static $_linkResultsCache = [];
36
+	private static $_mapResultsCache = [];
37 37
 
38 38
 	/**
39 39
 	 * @inheritdoc
40 40
 	 */
41
-	public function addObjectRequest($classType, array $filters=[], array $order=[], array $limit=[], $resultKey=null, $includeDeleted=false)
41
+	public function addObjectRequest($classType, array $filters = [], array $order = [], array $limit = [], $resultKey = null, $includeDeleted = false)
42 42
 	{
43 43
 		// protect ourselves against SQL injection by making sure all
44 44
 		// items are canonicalised as required (and use of PDO later)
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 					$data[$k] = self::$_requestResultsCache[$r['requestKey']];
106 106
 				} else {
107 107
 					// set null result information about the request
108
-					$newData[$k] = ['start'=>$r['limit']['start'],'length'=>0,'total'=>$r['total'],'rows'=>[]];
108
+					$newData[$k] = ['start'=>$r['limit']['start'], 'length'=>0, 'total'=>$r['total'], 'rows'=>[]];
109 109
 					$sql[] = $r['sql'];
110 110
 					if ($r['totalSql'])
111 111
 						$sql[] = $r['totalSql'];
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	/**
166 166
 	 * @inheritdoc
167 167
 	 */
168
-	public function runSingleObjectRequest($classType, array $filters=[], array $order=[], array $limit=[], $includeDeleted = false)
168
+	public function runSingleObjectRequest($classType, array $filters = [], array $order = [], array $limit = [], $includeDeleted = false)
169 169
 	{
170 170
 		if (empty($classType))
171 171
 			throw new \InvalidArgumentException('ClassType must be specified');
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	/**
190 190
 	 * @inheritdoc
191 191
 	 */
192
-	public function getObjectMap($classType, $filters=[], $fields=[], $start=0, $length=1000, $includeDeleted=false)
192
+	public function getObjectMap($classType, $filters = [], $fields = [], $start = 0, $length = 1000, $includeDeleted = false)
193 193
 	{
194 194
 		return $this->getObjectMapManager()->getObjectMap($classType, $filters, $fields, $start, $length, $includeDeleted);
195 195
 	}
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	/**
198 198
 	 * @inheritdoc
199 199
 	 */
200
-	public function makeMapLookupRequest($objectUuids, $mapFields=[], $classType=null)
200
+	public function makeMapLookupRequest($objectUuids, $mapFields = [], $classType = null)
201 201
 	{
202 202
 		return $this->getObjectMapManager()->makeMapLookupRequest($objectUuids, $mapFields, $classType);
203 203
 	}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	/**
206 206
 	 * @inheritdoc
207 207
 	 */
208
-	public function makeMapChainLookupRequest($objectUuids, $chainMembers=[], $chainMapFields=[], $inReverse=false)
208
+	public function makeMapChainLookupRequest($objectUuids, $chainMembers = [], $chainMapFields = [], $inReverse = false)
209 209
 	{
210 210
 		return $this->getObjectMapManager()->makeMapChainLookupRequest($objectUuids, $chainMembers, $chainMapFields, $inReverse);
211 211
 	}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	/**
249 249
 	 * @inheritdoc
250 250
 	 */
251
-	public function listObjects($classType, &$total=null, $includeDeleted=false, $inFull=true, $start=0, $length=100, $order=null)
251
+	public function listObjects($classType, &$total = null, $includeDeleted = false, $inFull = true, $start = 0, $length = 100, $order = null)
252 252
 	{
253 253
 		$classType = $this->canonicaliseRef($classType);
254 254
 		if (empty($order))
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
 		if (is_array($order)) {
281 281
 			$orderBits = [];
282 282
 			foreach ($order as $k=>$d) {
283
-				if ($k[1]=='o') {
283
+				if ($k[1] == 'o') {
284 284
 					$orderBits[] = "$k $d";
285 285
 				} else if ($inFull) {
286 286
 					$orderBits[] = "[[t]].$k $d";
287 287
 				}
288 288
 			}
289 289
 			if ($orderBits)
290
-				$orderClause = implode(', ',$orderBits);
290
+				$orderClause = implode(', ', $orderBits);
291 291
 			$query->orderBy($orderClause);
292 292
 		}
293 293
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	/**
300 300
 	 * @inheritdoc
301 301
 	 */
302
-	public function addObject($classType, array $data, &$changeLogUuid=null)
302
+	public function addObject($classType, array $data, &$changeLogUuid = null)
303 303
 	{
304 304
 		$class = null;
305 305
 		$classType = $this->canonicaliseRef($classType);
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$object->_created = $now;
318 318
 		$object->_updated = $now;
319 319
 		if (!$object->save())
320
-			throw new \RuntimeException("Couldn't create object: ".print_r($object->errors,true));
320
+			throw new \RuntimeException("Couldn't create object: ".print_r($object->errors, true));
321 321
 
322 322
 		// increment the class's object count
323 323
 		$class->count_total += 1;
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 			$values = [];
334 334
 			foreach (array_keys($memberStorage) as $memRef) {
335 335
 				// save all non-empty fields.
336
-				if (array_key_exists($memRef, $data) && $data[$memRef]!==null && $data[$memRef]!=='') {
336
+				if (array_key_exists($memRef, $data) && $data[$memRef] !== null && $data[$memRef] !== '') {
337 337
 					$fields[] = "`$memRef`";
338 338
 					$inserts[] = ":v$count";
339 339
 					$values[":v$count"] = $data[$memRef];
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			}
343 343
 
344 344
 			if (count($fields))
345
-				$query = "INSERT INTO `$table` (`_uuid`, ".implode(', ',$fields).") VALUES ('{$object->_uuid}', ".implode(', ', $inserts).")";
345
+				$query = "INSERT INTO `$table` (`_uuid`, ".implode(', ', $fields).") VALUES ('{$object->_uuid}', ".implode(', ', $inserts).")";
346 346
 			else
347 347
 				$query = "INSERT INTO `$table` (`_uuid`) VALUES ('{$object->_uuid}')";
348 348
 			$command = neon()->db->createCommand($query);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @inheritdoc
372 372
 	 */
373
-	public function addObjects($classType, array $data, $chunkSize=1000)
373
+	public function addObjects($classType, array $data, $chunkSize = 1000)
374 374
 	{
375 375
 		$classType = $this->canonicaliseRef($classType);
376 376
 		$class = null;
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		$columns[] = '_uuid';
389 389
 		$nullRow['_uuid'] = null;
390 390
 
391
-		foreach(array_chunk($data, $chunkSize) as $chunkData) {
391
+		foreach (array_chunk($data, $chunkSize) as $chunkData) {
392 392
 			$rows = [];
393 393
 			$objectDbRows = [];
394 394
 			$objectsLinks = [];
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 			neon()->db->createCommand()->batchInsert(DdsObject::tableName(), ['_uuid', '_class_type', '_created', '_updated'], $objectDbRows)->execute();
412 412
 			neon()->db->createCommand()->batchInsert($table, $columns, $rows)->execute();
413 413
 
414
-			foreach($objectsLinks as $uuid => $links) {
414
+			foreach ($objectsLinks as $uuid => $links) {
415 415
 				// if there are any links then add these to the link table
416 416
 				//
417 417
 				// TODO - make this a bulk insert across all data
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 			$table = $this->getTableFromClassType($object->_class_type);
436 436
 			$query = "SELECT `o`.*, `t`.* FROM `dds_object` `o` LEFT JOIN  `$table` `t` ON `o`.`_uuid`=`t`.`_uuid` WHERE `o`.`_uuid`=:uuid LIMIT 1";
437 437
 			$rows = neon()->db->createCommand($query)->bindValue(':uuid', $uuid)->queryAll();
438
-			$row =  count($rows) > 0 ? $rows[0] : null;
438
+			$row = count($rows) > 0 ? $rows[0] : null;
439 439
 			$this->convertFromDBToPHP($row, $this->getMemberLinks($uuid));
440 440
 			return $row;
441 441
 		}
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 	/**
446 446
 	 * @inheritdoc
447 447
 	 */
448
-	public function editObject($uuid, array $changes, &$changeLogUuid=null)
448
+	public function editObject($uuid, array $changes, &$changeLogUuid = null)
449 449
 	{
450 450
 		// check there are some changes to make
451
-		if (count($changes)==0)
451
+		if (count($changes) == 0)
452 452
 			return false;
453 453
 
454 454
 		// check that the object exists and find its class type
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
 					}
494 494
 				}
495 495
 			}
496
-			if (count($updates)==0)
496
+			if (count($updates) == 0)
497 497
 				return false;
498 498
 
499
-			$query = "UPDATE `$table` SET ".implode(', ',$updates)." WHERE `_uuid`='$uuid' LIMIT 1";
499
+			$query = "UPDATE `$table` SET ".implode(', ', $updates)." WHERE `_uuid`='$uuid' LIMIT 1";
500 500
 			neon()->db->createCommand($query)->bindValues($values)->execute();
501 501
 
502 502
 			// add or remove any links from the linking table
@@ -521,15 +521,15 @@  discard block
 block discarded – undo
521 521
 	 */
522 522
 	public function editObjects($classType, array $uuids, array $changes)
523 523
 	{
524
-		if (count($uuids)==0 || count($changes)==0)
524
+		if (count($uuids) == 0 || count($changes) == 0)
525 525
 			return false;
526 526
 		try {
527 527
 			$uuids = $this->checkUuidsAgainstClassType($uuids, $classType);
528
-			if (count($uuids)==0)
528
+			if (count($uuids) == 0)
529 529
 				return false;
530 530
 			$table = $this->getTableFromClassType($classType);
531 531
 			$memberStorage = $this->getMemberStorage($classType);
532
-			if (count($memberStorage)==0) {
532
+			if (count($memberStorage) == 0) {
533 533
 				throw new \InvalidArgumentException('Unknown or empty class type '.$classType);
534 534
 			}
535 535
 
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 					}
561 561
 				}
562 562
 			}
563
-			if (count($updates)==0)
563
+			if (count($updates) == 0)
564 564
 				return false;
565 565
 
566 566
 			// sort out the uuid clause for both the update on the table and in the object table
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			$query = "UPDATE `dds_object` SET `_updated`=NOW() WHERE `_uuid` IN $uuidClause LIMIT ".count($uuids);
581 581
 			$db->createCommand($query)->bindValues($objectValues)->execute();
582 582
 			// make the changes
583
-			$query = "UPDATE `$table` SET ".implode(', ',$updates)." WHERE `_uuid` IN $uuidClause LIMIT ".count($uuids);
583
+			$query = "UPDATE `$table` SET ".implode(', ', $updates)." WHERE `_uuid` IN $uuidClause LIMIT ".count($uuids);
584 584
 			$db->createCommand($query)->bindValues($values)->execute();
585 585
 
586 586
 			//
@@ -604,11 +604,11 @@  discard block
 block discarded – undo
604 604
 	/**
605 605
 	 * @inheritdoc
606 606
 	 */
607
-	public function deleteObject($uuid, &$changeLogUuid=null)
607
+	public function deleteObject($uuid, &$changeLogUuid = null)
608 608
 	{
609 609
 		$object = null;
610 610
 		// find the object and delete if it hasn't already been
611
-		if ($this->getObjectFromId($uuid, $object) && $object->_deleted==0) {
611
+		if ($this->getObjectFromId($uuid, $object) && $object->_deleted == 0) {
612 612
 			$object->_deleted = 1;
613 613
 			$object->_updated = date('Y-m-d H:i:s');
614 614
 			if (!$object->save())
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	public function deleteObjects(array $uuids)
643 643
 	{
644 644
 		$objects = $this->getObjectRowsFromIds($uuids);
645
-		if (count($objects)==0)
645
+		if (count($objects) == 0)
646 646
 			return;
647 647
 
648 648
 		$foundUuids = [];
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
 	/**
681 681
 	 * @inheritdoc
682 682
 	 */
683
-	public function undeleteObject($uuid, &$changeLogUuid=null)
683
+	public function undeleteObject($uuid, &$changeLogUuid = null)
684 684
 	{
685 685
 		$object = null;
686 686
 		// find the object and delete if it hasn't already been
687
-		if ($this->getObjectFromId($uuid, $object) && $object->_deleted==1) {
687
+		if ($this->getObjectFromId($uuid, $object) && $object->_deleted == 1) {
688 688
 			$object->_deleted = 0;
689 689
 			$object->_updated = date('Y-m-d H:i:s');
690 690
 			if (!$object->save())
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 			// and update the class object deleted count
694 694
 			$class = null;
695 695
 			if ($this->findClass($object['_class_type'], $class)) {
696
-				$class->count_deleted = max(0, $class->count_deleted-1);
696
+				$class->count_deleted = max(0, $class->count_deleted - 1);
697 697
 				$class->save();
698 698
 
699 699
 				// see if we need to store the change log
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 	/**
708 708
 	 * @inheritdoc
709 709
 	 */
710
-	public function destroyObject($uuid, &$changeLogUuid=null)
710
+	public function destroyObject($uuid, &$changeLogUuid = null)
711 711
 	{
712 712
 		$object = null;
713 713
 		if ($this->getObjectFromId($uuid, $object)) {
@@ -729,9 +729,9 @@  discard block
 block discarded – undo
729 729
 
730 730
 			// then if ok, decrement the class's object counts
731 731
 			if ($class) {
732
-				$class->count_total = max(0, $class->count_total-1);
732
+				$class->count_total = max(0, $class->count_total - 1);
733 733
 				if ($object['_deleted'] == 1)
734
-					$class->count_deleted = max(0, $class->count_deleted-1);
734
+					$class->count_deleted = max(0, $class->count_deleted - 1);
735 735
 				$class->save();
736 736
 			}
737 737
 
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	public function destroyObjects(array $uuids)
753 753
 	{
754 754
 		$objects = $this->getObjectRowsFromIds($uuids);
755
-		if (count($objects)==0)
755
+		if (count($objects) == 0)
756 756
 			return;
757 757
 
758 758
 		$objectUuids = [];
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 
788 788
 			// decrement the class's object counts
789 789
 			if ($class) {
790
-				$class->count_total = max(0, $class->count_total-count($uuids));
790
+				$class->count_total = max(0, $class->count_total - count($uuids));
791 791
 				if (isset($objectsDeleted[$classType]))
792
-					$class->count_deleted = max(0, $class->count_deleted-count($objectsDeleted[$classType]));
792
+					$class->count_deleted = max(0, $class->count_deleted - count($objectsDeleted[$classType]));
793 793
 				$class->save();
794 794
 			}
795 795
 		}
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 	 * @param [] &$dataSet  [n]=>$rows  rows of requested data
828 828
 	 * @param string $classTypeKey the key in the data that will give the class type
829 829
 	 */
830
-	private function convertResultsToPHP(&$dataSet, $links=null, $classTypeKey='_class_type')
830
+	private function convertResultsToPHP(&$dataSet, $links = null, $classTypeKey = '_class_type')
831 831
 	{
832 832
 		// if we haven't been provided any multilinks (even if empty array)
833 833
 		// then see if there are any multilinks to extract
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 * @param DdsObject &$object  the returned object
851 851
 	 * @return boolean  whether or not object found
852 852
 	 */
853
-	private function getObjectFromId($uuid, &$object=null)
853
+	private function getObjectFromId($uuid, &$object = null)
854 854
 	{
855 855
 		$object = DdsObject::find()->noCache()->where(['_uuid' => $uuid])->one();
856 856
 		return ($object !== null);
@@ -899,13 +899,13 @@  discard block
 block discarded – undo
899 899
 	 * @param string $resultKey  if provided use this else create one
900 900
 	 * @return string  return the resultKey
901 901
 	 */
902
-	private function createSqlAndStoreRequest(array $request, $resultKey=null)
902
+	private function createSqlAndStoreRequest(array $request, $resultKey = null)
903 903
 	{
904 904
 		// track number of calls to function to generate unique wthin one php request per call and per request result keys
905
-		static $counter = 0; $counter ++;
905
+		static $counter = 0; $counter++;
906 906
 		// a randomly generated resultKey prevents db query chaching.
907 907
 		$resultKey = $resultKey ? $resultKey : $request['requestKey'].'_'.$counter;
908
-		$request['resultKey' ] = $resultKey;
908
+		$request['resultKey'] = $resultKey;
909 909
 		if (!array_key_exists($request['requestKey'], self::$_requestResultsCache))
910 910
 			$this->convertRequestToSql($request);
911 911
 		// store the request
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 	private function convertRequestToSql(&$request)
964 964
 	{
965 965
 		$table = $this->getTableFromClassType($request['classType']);
966
-		$links = array_keys($this->getClassMembers($request['classType'], ['link_multi','file_ref_multi']));
966
+		$links = array_keys($this->getClassMembers($request['classType'], ['link_multi', 'file_ref_multi']));
967 967
 		$where = $this->extractWhereClause($request['filters'], $request['deleted'], $links, $filterKeys);
968 968
 		$join  = $this->extractJoinClause($links, $filterKeys);
969 969
 		$order = $this->extractOrderClause($request['order']);
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 	{
1003 1003
 		$filterKeys = [];
1004 1004
 		$notDeleted = '`o`.`_deleted`=0';
1005
-		if (count($filters)==0)
1005
+		if (count($filters) == 0)
1006 1006
 			return $includeDeleted ? '' : "WHERE $notDeleted";
1007 1007
 		$this->createFilterClause($filters, $links, $filterKeys);
1008 1008
 		if (!$includeDeleted)
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 		// Start creating the sql. $filters[0,1] will have been canonicalised, $filters[2] is protected using PDO
1088 1088
 		// Not all queries have a [2] though so should be just the operator (e.g. IS NULL)
1089 1089
 		//
1090
-		$filter = (in_array($filters[0], $links) ? "`link_{$filters[0]}`.`to_id`": $this->quoteField($filters[0]));
1090
+		$filter = (in_array($filters[0], $links) ? "`link_{$filters[0]}`.`to_id`" : $this->quoteField($filters[0]));
1091 1091
 		$filterKeys[$filters[0]] = $filters[0];
1092 1092
 		if ($this->operatorTakesObject($filters[1]) && isset($filters[2]))
1093 1093
 			$filters['itemSql'] = $filters['sql'] = "$filter ".$this->prepareForPDO($filters[1], $filters[2]);
@@ -1100,11 +1100,11 @@  discard block
 block discarded – undo
1100 1100
 	{
1101 1101
 		if (is_array($value)) {
1102 1102
 			$pdoValues = [];
1103
-			if (!in_array($operator, ['=','!=','IN','NOT IN']))
1103
+			if (!in_array($operator, ['=', '!=', 'IN', 'NOT IN']))
1104 1104
 				throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of values with an operator of $operator");
1105 1105
 			foreach ($value as $v) {
1106 1106
 				if (is_array($v))
1107
-					throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of *array* of values as filters (silly billy). You passed ".print_r($value,true));
1107
+					throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of *array* of values as filters (silly billy). You passed ".print_r($value, true));
1108 1108
 				$count = count($this->boundValues);
1109 1109
 				$variable = ":var{$count}end";
1110 1110
 				$this->boundValues[$variable] = $v;
@@ -1115,11 +1115,11 @@  discard block
 block discarded – undo
1115 1115
 				$operator = 'IN';
1116 1116
 			if ($operator == '!=')
1117 1117
 				$operator = 'NOT IN';
1118
-			return "$operator (".implode(',',$pdoValues).')';
1118
+			return "$operator (".implode(',', $pdoValues).')';
1119 1119
 		} else {
1120 1120
 			$count = count($this->boundValues);
1121 1121
 			$variable = ":var{$count}end";
1122
-			if (strpos(strtolower($operator), 'like')!==false) {
1122
+			if (strpos(strtolower($operator), 'like') !== false) {
1123 1123
 				$this->boundValues[$variable] = "%$value%";
1124 1124
 				return "$operator $variable";
1125 1125
 			} else if (strpos(strtolower($operator), 'null') !== false) {
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 	 */
1139 1139
 	private function extractOrderClause($order)
1140 1140
 	{
1141
-		if (count($order)==0)
1141
+		if (count($order) == 0)
1142 1142
 			return '';
1143 1143
 		$clause = [];
1144 1144
 		foreach ($order as $o => $d) {
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
 				break;
1149 1149
 			}
1150 1150
 			// allow negative ordering in mysql for nulls last
1151
-			if (strpos($o, '-')===0)
1151
+			if (strpos($o, '-') === 0)
1152 1152
 				$clause[] = '-'.substr($o, 1)." $d";
1153 1153
 			else
1154 1154
 				$clause[] = "$o $d";
1155 1155
 		}
1156
-		return 'ORDER BY '.implode(', ',$clause);
1156
+		return 'ORDER BY '.implode(', ', $clause);
1157 1157
 	}
1158 1158
 
1159 1159
 	/**
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 	 */
1164 1164
 	private function extractLimitClause($limit)
1165 1165
 	{
1166
-		if (count($limit)==0)
1166
+		if (count($limit) == 0)
1167 1167
 			return '';
1168 1168
 		return "LIMIT $limit[start], $limit[length]";
1169 1169
 	}
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 			if (!is_array($toLinks))
1188 1188
 				$toLinks = [$toLinks];
1189 1189
 			if (!$this->areUUIDs($toLinks))
1190
-				throw new \InvalidArgumentException("The toMemberLinks should be UUID64s. You passed in ".print_r($toLinks,true));
1190
+				throw new \InvalidArgumentException("The toMemberLinks should be UUID64s. You passed in ".print_r($toLinks, true));
1191 1191
 			array_unique($toLinks);
1192 1192
 
1193 1193
 			//
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 				$batchInsert[] = ['from_id'=>$fromLink, 'from_member'=>$member, 'to_id'=>$toLink];
1208 1208
 			$memberCount = 0;
1209 1209
 			if (count($batchInsert))
1210
-				$memberCount = neon()->db->createCommand()->batchInsert('{{%dds_link}}', ['from_id','from_member','to_id'], $batchInsert)->execute();
1210
+				$memberCount = neon()->db->createCommand()->batchInsert('{{%dds_link}}', ['from_id', 'from_member', 'to_id'], $batchInsert)->execute();
1211 1211
 			if (YII_DEBUG && $memberCount !== $batchCount)
1212 1212
 				throw new Exception("The link insertion failed for member $member - $batchCount items should have been inserted vs $memberCount actual");
1213 1213
 			$count += $memberCount;
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
 	 * @param array $changes  what the changes are
1265 1265
 	 * @return string  the uuid of the log entry
1266 1266
 	 */
1267
-	private function createChangeLogEntry($class, $changeKey, $objectUuid, $originalValues=[], $newValues=[])
1267
+	private function createChangeLogEntry($class, $changeKey, $objectUuid, $originalValues = [], $newValues = [])
1268 1268
 	{
1269 1269
 		static $changeLog = null;
1270 1270
 		if (!$changeLog)
Please login to merge, or discard this patch.
Braces   +203 added lines, -140 removed lines patch added patch discarded remove patch
@@ -107,8 +107,9 @@  discard block
 block discarded – undo
107 107
 					// set null result information about the request
108 108
 					$newData[$k] = ['start'=>$r['limit']['start'],'length'=>0,'total'=>$r['total'],'rows'=>[]];
109 109
 					$sql[] = $r['sql'];
110
-					if ($r['totalSql'])
111
-						$sql[] = $r['totalSql'];
110
+					if ($r['totalSql']) {
111
+											$sql[] = $r['totalSql'];
112
+					}
112 113
 					$resultKey2RequestKey[$r['resultKey']] = $r['requestKey'];
113 114
 				}
114 115
 			}
@@ -167,8 +168,9 @@  discard block
 block discarded – undo
167 168
 	 */
168 169
 	public function runSingleObjectRequest($classType, array $filters=[], array $order=[], array $limit=[], $includeDeleted = false)
169 170
 	{
170
-		if (empty($classType))
171
-			throw new \InvalidArgumentException('ClassType must be specified');
171
+		if (empty($classType)) {
172
+					throw new \InvalidArgumentException('ClassType must be specified');
173
+		}
172 174
 
173 175
 		// make sure that any currently queued requests from elsewhere are saved off the queue
174 176
 		$currentRequests = $this->popRequests();
@@ -251,16 +253,18 @@  discard block
 block discarded – undo
251 253
 	public function listObjects($classType, &$total=null, $includeDeleted=false, $inFull=true, $start=0, $length=100, $order=null)
252 254
 	{
253 255
 		$classType = $this->canonicaliseRef($classType);
254
-		if (empty($order))
255
-			$order = ['_created'=>'DESC'];
256
+		if (empty($order)) {
257
+					$order = ['_created'=>'DESC'];
258
+		}
256 259
 		$order = $this->canonicaliseOrder($order);
257 260
 
258 261
 		// get the total first
259 262
 		$class = null;
260 263
 		$this->findClass($classType, $class, true);
261 264
 		$total = $class->count_total;
262
-		if (!$includeDeleted)
263
-			$total -= $class->count_deleted;
265
+		if (!$includeDeleted) {
266
+					$total -= $class->count_deleted;
267
+		}
264 268
 
265 269
 		// now get the objects
266 270
 		$query = (new \neon\core\db\Query)
@@ -270,8 +274,9 @@  discard block
 block discarded – undo
270 274
 			->offset($start)
271 275
 			->limit($length);
272 276
 
273
-		if (!$includeDeleted)
274
-			$query->andWhere('[[o]].[[_deleted]] = 0');
277
+		if (!$includeDeleted) {
278
+					$query->andWhere('[[o]].[[_deleted]] = 0');
279
+		}
275 280
 		if ($inFull) {
276 281
 			$tableName = $this->getTableFromClassType($classType);
277 282
 			$query->innerJoin('{{'.$tableName.'}} t', '[[o]].[[_uuid]]=[[t]].[[_uuid]]');
@@ -286,8 +291,9 @@  discard block
 block discarded – undo
286 291
 					$orderBits[] = "[[t]].$k $d";
287 292
 				}
288 293
 			}
289
-			if ($orderBits)
290
-				$orderClause = implode(', ',$orderBits);
294
+			if ($orderBits) {
295
+							$orderClause = implode(', ',$orderBits);
296
+			}
291 297
 			$query->orderBy($orderClause);
292 298
 		}
293 299
 
@@ -304,8 +310,9 @@  discard block
 block discarded – undo
304 310
 		$class = null;
305 311
 		$classType = $this->canonicaliseRef($classType);
306 312
 		$this->findClass($classType, $class, true);
307
-		if ($class->hasChangeLog())
308
-			$newValues = $data;
313
+		if ($class->hasChangeLog()) {
314
+					$newValues = $data;
315
+		}
309 316
 		$table = $this->getTableFromClassType($classType);
310 317
 
311 318
 		// create the new object
@@ -316,8 +323,9 @@  discard block
 block discarded – undo
316 323
 		$object->_class_type = $classType;
317 324
 		$object->_created = $now;
318 325
 		$object->_updated = $now;
319
-		if (!$object->save())
320
-			throw new \RuntimeException("Couldn't create object: ".print_r($object->errors,true));
326
+		if (!$object->save()) {
327
+					throw new \RuntimeException("Couldn't create object: ".print_r($object->errors,true));
328
+		}
321 329
 
322 330
 		// increment the class's object count
323 331
 		$class->count_total += 1;
@@ -341,10 +349,11 @@  discard block
 block discarded – undo
341 349
 				}
342 350
 			}
343 351
 
344
-			if (count($fields))
345
-				$query = "INSERT INTO `$table` (`_uuid`, ".implode(', ',$fields).") VALUES ('{$object->_uuid}', ".implode(', ', $inserts).")";
346
-			else
347
-				$query = "INSERT INTO `$table` (`_uuid`) VALUES ('{$object->_uuid}')";
352
+			if (count($fields)) {
353
+							$query = "INSERT INTO `$table` (`_uuid`, ".implode(', ',$fields).") VALUES ('{$object->_uuid}', ".implode(', ', $inserts).")";
354
+			} else {
355
+							$query = "INSERT INTO `$table` (`_uuid`) VALUES ('{$object->_uuid}')";
356
+			}
348 357
 			$command = neon()->db->createCommand($query);
349 358
 			$command->bindValues($values);
350 359
 			$command->execute();
@@ -352,8 +361,9 @@  discard block
 block discarded – undo
352 361
 			// if there are any links then add these to the link table
353 362
 			$this->setMemberLinks($object->_uuid, $links);
354 363
 
355
-			if ($class->hasChangeLog())
356
-				$changeLogUuid = $this->createChangeLogEntry($class, 'ADD', $object->_uuid, [], $newValues);
364
+			if ($class->hasChangeLog()) {
365
+							$changeLogUuid = $this->createChangeLogEntry($class, 'ADD', $object->_uuid, [], $newValues);
366
+			}
357 367
 		} catch (\Exception $e) {
358 368
 			// execution failed so clean up the object
359 369
 			$object->delete();
@@ -394,8 +404,9 @@  discard block
 block discarded – undo
394 404
 			$objectsLinks = [];
395 405
 			$now = date('Y-m-d H:i:s');
396 406
 			foreach ($chunkData as $row) {
397
-				if ($class->hasChangeLog())
398
-					$newValues = $row;
407
+				if ($class->hasChangeLog()) {
408
+									$newValues = $row;
409
+				}
399 410
 				// ddt table value - format row data and append the uuid
400 411
 				$this->convertFromPHPToDB($classType, $row, $links);
401 412
 				$uuid = (!empty($row['_uuid']) && $this->isUUID($row['_uuid'])) ? $row['_uuid'] : $this->generateUUID();
@@ -405,8 +416,9 @@  discard block
 block discarded – undo
405 416
 				// object table row value
406 417
 				$objectDbRows[] = [$row['_uuid'], $classType, $now, $now];
407 418
 				$objectsLinks[$row['_uuid']] = $links;
408
-				if ($class->hasChangeLog())
409
-					$this->createChangeLogEntry($class, 'ADD', $uuid, [], $newValues);
419
+				if ($class->hasChangeLog()) {
420
+									$this->createChangeLogEntry($class, 'ADD', $uuid, [], $newValues);
421
+				}
410 422
 			}
411 423
 			neon()->db->createCommand()->batchInsert(DdsObject::tableName(), ['_uuid', '_class_type', '_created', '_updated'], $objectDbRows)->execute();
412 424
 			neon()->db->createCommand()->batchInsert($table, $columns, $rows)->execute();
@@ -448,20 +460,23 @@  discard block
 block discarded – undo
448 460
 	public function editObject($uuid, array $changes, &$changeLogUuid=null)
449 461
 	{
450 462
 		// check there are some changes to make
451
-		if (count($changes)==0)
452
-			return false;
463
+		if (count($changes)==0) {
464
+					return false;
465
+		}
453 466
 
454 467
 		// check that the object exists and find its class type
455
-		if (!$this->getObjectFromId($uuid, $object))
456
-			throw new \InvalidArgumentException("Couldn't edit object with id $uuid as not found");
468
+		if (!$this->getObjectFromId($uuid, $object)) {
469
+					throw new \InvalidArgumentException("Couldn't edit object with id $uuid as not found");
470
+		}
457 471
 
458 472
 		// see if we need to store the change log
459 473
 		$class = null;
460 474
 		$this->findClass($object['_class_type'], $class);
461 475
 
462 476
 		$object->_updated = date('Y-m-d H:i:s');
463
-		if (!$object->save())
464
-			return $object->errors;
477
+		if (!$object->save()) {
478
+					return $object->errors;
479
+		}
465 480
 
466 481
 		// now update any member changes
467 482
 		try {
@@ -493,8 +508,9 @@  discard block
 block discarded – undo
493 508
 					}
494 509
 				}
495 510
 			}
496
-			if (count($updates)==0)
497
-				return false;
511
+			if (count($updates)==0) {
512
+							return false;
513
+			}
498 514
 
499 515
 			$query = "UPDATE `$table` SET ".implode(', ',$updates)." WHERE `_uuid`='$uuid' LIMIT 1";
500 516
 			neon()->db->createCommand($query)->bindValues($values)->execute();
@@ -503,8 +519,9 @@  discard block
 block discarded – undo
503 519
 			$this->setMemberLinks($object->_uuid, $links);
504 520
 
505 521
 			// finally note the changes in the change log
506
-			if ($class && $class->hasChangeLog())
507
-				$changeLogUuid = $this->createChangeLogEntry($class, 'EDIT', $uuid, $originalValues, $newValues);
522
+			if ($class && $class->hasChangeLog()) {
523
+							$changeLogUuid = $this->createChangeLogEntry($class, 'EDIT', $uuid, $originalValues, $newValues);
524
+			}
508 525
 
509 526
 		} catch (\yii\db\exception $e) {
510 527
 			$this->clearCaches();
@@ -521,12 +538,14 @@  discard block
 block discarded – undo
521 538
 	 */
522 539
 	public function editObjects($classType, array $uuids, array $changes)
523 540
 	{
524
-		if (count($uuids)==0 || count($changes)==0)
525
-			return false;
541
+		if (count($uuids)==0 || count($changes)==0) {
542
+					return false;
543
+		}
526 544
 		try {
527 545
 			$uuids = $this->checkUuidsAgainstClassType($uuids, $classType);
528
-			if (count($uuids)==0)
529
-				return false;
546
+			if (count($uuids)==0) {
547
+							return false;
548
+			}
530 549
 			$table = $this->getTableFromClassType($classType);
531 550
 			$memberStorage = $this->getMemberStorage($classType);
532 551
 			if (count($memberStorage)==0) {
@@ -537,8 +556,9 @@  discard block
 block discarded – undo
537 556
 			$class = null;
538 557
 			$this->findClass($classType, $class);
539 558
 			if ($class && $class->hasChangeLog()) {
540
-				foreach ($uuids as $uuid)
541
-					$beforeValues[$uuid] = array_intersect_key($this->getObject($uuid), $changes);
559
+				foreach ($uuids as $uuid) {
560
+									$beforeValues[$uuid] = array_intersect_key($this->getObject($uuid), $changes);
561
+				}
542 562
 				$newValues = $changes;
543 563
 			}
544 564
 
@@ -560,8 +580,9 @@  discard block
 block discarded – undo
560 580
 					}
561 581
 				}
562 582
 			}
563
-			if (count($updates)==0)
564
-				return false;
583
+			if (count($updates)==0) {
584
+							return false;
585
+			}
565 586
 
566 587
 			// sort out the uuid clause for both the update on the table and in the object table
567 588
 			$uuidClause = [];
@@ -589,8 +610,9 @@  discard block
 block discarded – undo
589 610
 
590 611
 			// and save entries into a change log
591 612
 			if ($class && $class->hasChangeLog()) {
592
-				foreach ($beforeValues as $uuid=>$before)
593
-					$this->createChangeLogEntry($class, 'EDIT', $uuid, $before, $newValues);
613
+				foreach ($beforeValues as $uuid=>$before) {
614
+									$this->createChangeLogEntry($class, 'EDIT', $uuid, $before, $newValues);
615
+				}
594 616
 			}
595 617
 
596 618
 		} catch (\yii\db\exception $e) {
@@ -611,8 +633,9 @@  discard block
 block discarded – undo
611 633
 		if ($this->getObjectFromId($uuid, $object) && $object->_deleted==0) {
612 634
 			$object->_deleted = 1;
613 635
 			$object->_updated = date('Y-m-d H:i:s');
614
-			if (!$object->save())
615
-				throw new \RuntimeException("Couldn't delete the object: ".print_r($object->errors, true));
636
+			if (!$object->save()) {
637
+							throw new \RuntimeException("Couldn't delete the object: ".print_r($object->errors, true));
638
+			}
616 639
 			// and update the class object deleted count
617 640
 			$class = null;
618 641
 			$this->findClass($object['_class_type'], $class);
@@ -620,8 +643,9 @@  discard block
 block discarded – undo
620 643
 			$class->save();
621 644
 
622 645
 			// see if we need to store the change log
623
-			if ($class && $class->hasChangeLog())
624
-				$changeLogUuid = $this->createChangeLogEntry($class, 'DELETE', $uuid);
646
+			if ($class && $class->hasChangeLog()) {
647
+							$changeLogUuid = $this->createChangeLogEntry($class, 'DELETE', $uuid);
648
+			}
625 649
 
626 650
 			// ---- KEEP ME ----
627 651
 			// on't delete the links so any that haven't been deleted between
@@ -642,8 +666,9 @@  discard block
 block discarded – undo
642 666
 	public function deleteObjects(array $uuids)
643 667
 	{
644 668
 		$objects = $this->getObjectRowsFromIds($uuids);
645
-		if (count($objects)==0)
646
-			return;
669
+		if (count($objects)==0) {
670
+					return;
671
+		}
647 672
 
648 673
 		$foundUuids = [];
649 674
 		$foundClasses = [];
@@ -660,8 +685,9 @@  discard block
 block discarded – undo
660 685
 				$deletedUuids[$classType][$obj['_uuid']] = $obj['_uuid'];
661 686
 			}
662 687
 		}
663
-		if (count($foundUuids))
664
-			DdsObject::updateAll(['_deleted'=>1, '_updated'=>date('Y-m-d H:i:s')], ['_uuid'=>$foundUuids]);
688
+		if (count($foundUuids)) {
689
+					DdsObject::updateAll(['_deleted'=>1, '_updated'=>date('Y-m-d H:i:s')], ['_uuid'=>$foundUuids]);
690
+		}
665 691
 		foreach ($foundClasses as $type=>$count) {
666 692
 			$class = null;
667 693
 			if ($this->findClass($type, $class)) {
@@ -669,8 +695,9 @@  discard block
 block discarded – undo
669 695
 				$class->save();
670 696
 				// TODO 20200107 Make a bulk call for change log entries
671 697
 				if ($class->hasChangeLog()) {
672
-					foreach ($deletedUuids[$class->class_type] as $objUuid)
673
-						$this->createChangeLogEntry($class, 'DELETE', $objUuid);
698
+					foreach ($deletedUuids[$class->class_type] as $objUuid) {
699
+											$this->createChangeLogEntry($class, 'DELETE', $objUuid);
700
+					}
674 701
 				}
675 702
 			}
676 703
 		}
@@ -687,8 +714,9 @@  discard block
 block discarded – undo
687 714
 		if ($this->getObjectFromId($uuid, $object) && $object->_deleted==1) {
688 715
 			$object->_deleted = 0;
689 716
 			$object->_updated = date('Y-m-d H:i:s');
690
-			if (!$object->save())
691
-				throw new \RuntimeException("Couldn't undelete the object: ".print_r($object->errors, true));
717
+			if (!$object->save()) {
718
+							throw new \RuntimeException("Couldn't undelete the object: ".print_r($object->errors, true));
719
+			}
692 720
 
693 721
 			// and update the class object deleted count
694 722
 			$class = null;
@@ -697,8 +725,9 @@  discard block
 block discarded – undo
697 725
 				$class->save();
698 726
 
699 727
 				// see if we need to store the change log
700
-				if ($class->hasChangeLog())
701
-					$changeLogUuid = $this->createChangeLogEntry($class, 'UNDELETE', $uuid);
728
+				if ($class->hasChangeLog()) {
729
+									$changeLogUuid = $this->createChangeLogEntry($class, 'UNDELETE', $uuid);
730
+				}
702 731
 			}
703 732
 			$this->clearCaches();
704 733
 		}
@@ -713,8 +742,9 @@  discard block
 block discarded – undo
713 742
 		if ($this->getObjectFromId($uuid, $object)) {
714 743
 			$class = null;
715 744
 			$this->findClass($object['_class_type'], $class);
716
-			if ($class && $class->hasChangeLog())
717
-				$originalValues = $this->getObject($uuid);
745
+			if ($class && $class->hasChangeLog()) {
746
+							$originalValues = $this->getObject($uuid);
747
+			}
718 748
 
719 749
 			// delete any object table data
720 750
 			$table = $this->getTableFromClassType($object['_class_type']);
@@ -730,8 +760,9 @@  discard block
 block discarded – undo
730 760
 			// then if ok, decrement the class's object counts
731 761
 			if ($class) {
732 762
 				$class->count_total = max(0, $class->count_total-1);
733
-				if ($object['_deleted'] == 1)
734
-					$class->count_deleted = max(0, $class->count_deleted-1);
763
+				if ($object['_deleted'] == 1) {
764
+									$class->count_deleted = max(0, $class->count_deleted-1);
765
+				}
735 766
 				$class->save();
736 767
 			}
737 768
 
@@ -739,8 +770,9 @@  discard block
 block discarded – undo
739 770
 			DdsLink::deleteAll(['or', ['from_id'=>$uuid], ['to_id'=>$uuid]]);
740 771
 
741 772
 			// and note this is in the change log
742
-			if ($class && $class->hasChangeLog())
743
-				$changeLogUuid = $this->createChangeLogEntry($class, 'DESTROY', $uuid, $originalValues);
773
+			if ($class && $class->hasChangeLog()) {
774
+							$changeLogUuid = $this->createChangeLogEntry($class, 'DESTROY', $uuid, $originalValues);
775
+			}
744 776
 
745 777
 			$this->clearCaches();
746 778
 		}
@@ -752,16 +784,18 @@  discard block
 block discarded – undo
752 784
 	public function destroyObjects(array $uuids)
753 785
 	{
754 786
 		$objects = $this->getObjectRowsFromIds($uuids);
755
-		if (count($objects)==0)
756
-			return;
787
+		if (count($objects)==0) {
788
+					return;
789
+		}
757 790
 
758 791
 		$objectUuids = [];
759 792
 		$objectsDeleted = [];
760 793
 		$classUuids = [];
761 794
 		foreach ($objects as $obj) {
762 795
 			$objectUuids[$obj['_uuid']] = $obj['_uuid'];
763
-			if ($obj['_deleted'] == 1)
764
-				$objectsDeleted[$obj['_class_type']][$obj['_uuid']] = $obj['_uuid'];
796
+			if ($obj['_deleted'] == 1) {
797
+							$objectsDeleted[$obj['_class_type']][$obj['_uuid']] = $obj['_uuid'];
798
+			}
765 799
 			$classUuids[$obj['_class_type']][] = $obj['_uuid'];
766 800
 		}
767 801
 
@@ -788,8 +822,9 @@  discard block
 block discarded – undo
788 822
 			// decrement the class's object counts
789 823
 			if ($class) {
790 824
 				$class->count_total = max(0, $class->count_total-count($uuids));
791
-				if (isset($objectsDeleted[$classType]))
792
-					$class->count_deleted = max(0, $class->count_deleted-count($objectsDeleted[$classType]));
825
+				if (isset($objectsDeleted[$classType])) {
826
+									$class->count_deleted = max(0, $class->count_deleted-count($objectsDeleted[$classType]));
827
+				}
793 828
 				$class->save();
794 829
 			}
795 830
 		}
@@ -817,8 +852,9 @@  discard block
 block discarded – undo
817 852
 	 */
818 853
 	private function getObjectMapManager()
819 854
 	{
820
-		if (!$this->_objectMapManager)
821
-			$this->_objectMapManager = new DdsObjectMapManager;
855
+		if (!$this->_objectMapManager) {
856
+					$this->_objectMapManager = new DdsObjectMapManager;
857
+		}
822 858
 		return $this->_objectMapManager;
823 859
 	}
824 860
 
@@ -833,14 +869,16 @@  discard block
 block discarded – undo
833 869
 		// then see if there are any multilinks to extract
834 870
 		if ($links === null) {
835 871
 			$objectIds = [];
836
-			foreach ($dataSet as $row)
837
-				$objectIds[] = $row['_uuid'];
872
+			foreach ($dataSet as $row) {
873
+							$objectIds[] = $row['_uuid'];
874
+			}
838 875
 			$links = $this->getMembersLinks($objectIds);
839 876
 		}
840 877
 		foreach ($dataSet as &$data) {
841 878
 			// convert full rows to database. Totals are left untouched
842
-			if (isset($data[$classTypeKey]))
843
-				$this->convertFromDBToPHP($data, $links[$data['_uuid']], $classTypeKey);
879
+			if (isset($data[$classTypeKey])) {
880
+							$this->convertFromDBToPHP($data, $links[$data['_uuid']], $classTypeKey);
881
+			}
844 882
 		}
845 883
 	}
846 884
 
@@ -906,8 +944,9 @@  discard block
 block discarded – undo
906 944
 		// a randomly generated resultKey prevents db query chaching.
907 945
 		$resultKey = $resultKey ? $resultKey : $request['requestKey'].'_'.$counter;
908 946
 		$request['resultKey' ] = $resultKey;
909
-		if (!array_key_exists($request['requestKey'], self::$_requestResultsCache))
910
-			$this->convertRequestToSql($request);
947
+		if (!array_key_exists($request['requestKey'], self::$_requestResultsCache)) {
948
+					$this->convertRequestToSql($request);
949
+		}
911 950
 		// store the request
912 951
 		$this->objectRequests[$request['classType']][$resultKey] = $request;
913 952
 		return $resultKey;
@@ -984,8 +1023,9 @@  discard block
 block discarded – undo
984 1023
 	{
985 1024
 		$join = ['INNER JOIN dds_object `o` on `t`.`_uuid` = `o`.`_uuid`'];
986 1025
 		foreach ($links as $l) {
987
-			if (in_array($l, $filterKeys))
988
-				$join[] = "LEFT JOIN dds_link `link_$l` ON (`link_$l`.`from_id`=`o`.`_uuid` AND `link_$l`.`from_member`='$l')";
1026
+			if (in_array($l, $filterKeys)) {
1027
+							$join[] = "LEFT JOIN dds_link `link_$l` ON (`link_$l`.`from_id`=`o`.`_uuid` AND `link_$l`.`from_member`='$l')";
1028
+			}
989 1029
 		}
990 1030
 		return implode(' ', $join);
991 1031
 	}
@@ -1002,11 +1042,13 @@  discard block
 block discarded – undo
1002 1042
 	{
1003 1043
 		$filterKeys = [];
1004 1044
 		$notDeleted = '`o`.`_deleted`=0';
1005
-		if (count($filters)==0)
1006
-			return $includeDeleted ? '' : "WHERE $notDeleted";
1045
+		if (count($filters)==0) {
1046
+					return $includeDeleted ? '' : "WHERE $notDeleted";
1047
+		}
1007 1048
 		$this->createFilterClause($filters, $links, $filterKeys);
1008
-		if (!$includeDeleted)
1009
-			return "WHERE $notDeleted AND ($filters[sql])";
1049
+		if (!$includeDeleted) {
1050
+					return "WHERE $notDeleted AND ($filters[sql])";
1051
+		}
1010 1052
 		return "WHERE $filters[sql]";
1011 1053
 	}
1012 1054
 
@@ -1023,8 +1065,9 @@  discard block
 block discarded – undo
1023 1065
 		// filter down until we hit the actual filters
1024 1066
 		if (is_array($filters[0])) {
1025 1067
 			foreach ($filters as $k => &$filter) {
1026
-				if ($k === 'logic')
1027
-					continue;
1068
+				if ($k === 'logic') {
1069
+									continue;
1070
+				}
1028 1071
 				$this->createFilterClause($filter, $links, $filterKeys);
1029 1072
 			}
1030 1073
 			//
@@ -1035,25 +1078,28 @@  discard block
 block discarded – undo
1035 1078
 				// in which case we combine those with to get the filterSql
1036 1079
 				$filterSql = [];
1037 1080
 				foreach ($filters as $k => &$filter) {
1038
-					if ($k === 'logic')
1039
-						continue;
1081
+					if ($k === 'logic') {
1082
+											continue;
1083
+					}
1040 1084
 					// use the logic keys if any for the items - these can be in position 3
1041 1085
 					// for most operators and position 2 for operators that don't take a key
1042 1086
 					if ($this->operatorTakesObject($filter[1])) {
1043
-						if (isset($filter[3]))
1044
-							$filterSql[$filter[3]] = $filter['itemSql'];
1045
-						else
1046
-							$filterSql[] = $filter['itemSql'];
1087
+						if (isset($filter[3])) {
1088
+													$filterSql[$filter[3]] = $filter['itemSql'];
1089
+						} else {
1090
+													$filterSql[] = $filter['itemSql'];
1091
+						}
1047 1092
 					} else {
1048
-						if (isset($filter[2]))
1049
-							$filterSql[$filter[2]] = $filter['itemSql'];
1050
-						else
1051
-							$filterSql[] = $filter['itemSql'];
1093
+						if (isset($filter[2])) {
1094
+													$filterSql[$filter[2]] = $filter['itemSql'];
1095
+						} else {
1096
+													$filterSql[] = $filter['itemSql'];
1097
+						}
1052 1098
 					}
1053 1099
 				}
1054
-				if (empty($filters['logic']))
1055
-					$filters['filterSql'] = $filters['sql'] = implode(' AND ', $filterSql);
1056
-				else {
1100
+				if (empty($filters['logic'])) {
1101
+									$filters['filterSql'] = $filters['sql'] = implode(' AND ', $filterSql);
1102
+				} else {
1057 1103
 					// make sure we test logic filters in order from longest key to shortest key
1058 1104
 					// otherwise we can end up with subkeys screwing things up
1059 1105
 					$orderedKeys = array_map('strlen', array_keys($filterSql));
@@ -1065,8 +1111,9 @@  discard block
 block discarded – undo
1065 1111
 					// double conversion,
1066 1112
 					$keys = array_keys($filterSql);
1067 1113
 					$keys2hashed = array();
1068
-					foreach ($keys as $k)
1069
-						$keys2hashed[$k] = md5($k);
1114
+					foreach ($keys as $k) {
1115
+											$keys2hashed[$k] = md5($k);
1116
+					}
1070 1117
 					$logicPass1 = str_replace($keys, $keys2hashed, $filters['logic']);
1071 1118
 					$filters['filterSql'] = $filters['sql'] = str_replace($keys2hashed, array_values($filterSql), $logicPass1);
1072 1119
 				}
@@ -1089,9 +1136,9 @@  discard block
 block discarded – undo
1089 1136
 		//
1090 1137
 		$filter = (in_array($filters[0], $links) ? "`link_{$filters[0]}`.`to_id`": $this->quoteField($filters[0]));
1091 1138
 		$filterKeys[$filters[0]] = $filters[0];
1092
-		if ($this->operatorTakesObject($filters[1]) && isset($filters[2]))
1093
-			$filters['itemSql'] = $filters['sql'] = "$filter ".$this->prepareForPDO($filters[1], $filters[2]);
1094
-		else {
1139
+		if ($this->operatorTakesObject($filters[1]) && isset($filters[2])) {
1140
+					$filters['itemSql'] = $filters['sql'] = "$filter ".$this->prepareForPDO($filters[1], $filters[2]);
1141
+		} else {
1095 1142
 			$filters['itemSql'] = $filters['sql'] = "$filter $filters[1]";
1096 1143
 		}
1097 1144
 	}
@@ -1100,21 +1147,25 @@  discard block
 block discarded – undo
1100 1147
 	{
1101 1148
 		if (is_array($value)) {
1102 1149
 			$pdoValues = [];
1103
-			if (!in_array($operator, ['=','!=','IN','NOT IN']))
1104
-				throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of values with an operator of $operator");
1150
+			if (!in_array($operator, ['=','!=','IN','NOT IN'])) {
1151
+							throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of values with an operator of $operator");
1152
+			}
1105 1153
 			foreach ($value as $v) {
1106
-				if (is_array($v))
1107
-					throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of *array* of values as filters (silly billy). You passed ".print_r($value,true));
1154
+				if (is_array($v)) {
1155
+									throw new \InvalidArgumentException("Daedalus: Cannot pass an *array* of *array* of values as filters (silly billy). You passed ".print_r($value,true));
1156
+				}
1108 1157
 				$count = count($this->boundValues);
1109 1158
 				$variable = ":var{$count}end";
1110 1159
 				$this->boundValues[$variable] = $v;
1111 1160
 				$pdoValues[] = $variable;
1112 1161
 			}
1113 1162
 			// converts equals to ins and outs
1114
-			if ($operator == '=')
1115
-				$operator = 'IN';
1116
-			if ($operator == '!=')
1117
-				$operator = 'NOT IN';
1163
+			if ($operator == '=') {
1164
+							$operator = 'IN';
1165
+			}
1166
+			if ($operator == '!=') {
1167
+							$operator = 'NOT IN';
1168
+			}
1118 1169
 			return "$operator (".implode(',',$pdoValues).')';
1119 1170
 		} else {
1120 1171
 			$count = count($this->boundValues);
@@ -1138,8 +1189,9 @@  discard block
 block discarded – undo
1138 1189
 	 */
1139 1190
 	private function extractOrderClause($order)
1140 1191
 	{
1141
-		if (count($order)==0)
1142
-			return '';
1192
+		if (count($order)==0) {
1193
+					return '';
1194
+		}
1143 1195
 		$clause = [];
1144 1196
 		foreach ($order as $o => $d) {
1145 1197
 			// if any of the order clauses are RAND then replace whole clause
@@ -1148,10 +1200,11 @@  discard block
 block discarded – undo
1148 1200
 				break;
1149 1201
 			}
1150 1202
 			// allow negative ordering in mysql for nulls last
1151
-			if (strpos($o, '-')===0)
1152
-				$clause[] = '-'.substr($o, 1)." $d";
1153
-			else
1154
-				$clause[] = "$o $d";
1203
+			if (strpos($o, '-')===0) {
1204
+							$clause[] = '-'.substr($o, 1)." $d";
1205
+			} else {
1206
+							$clause[] = "$o $d";
1207
+			}
1155 1208
 		}
1156 1209
 		return 'ORDER BY '.implode(', ',$clause);
1157 1210
 	}
@@ -1163,8 +1216,9 @@  discard block
 block discarded – undo
1163 1216
 	 */
1164 1217
 	private function extractLimitClause($limit)
1165 1218
 	{
1166
-		if (count($limit)==0)
1167
-			return '';
1219
+		if (count($limit)==0) {
1220
+					return '';
1221
+		}
1168 1222
 		return "LIMIT $limit[start], $limit[length]";
1169 1223
 	}
1170 1224
 
@@ -1180,14 +1234,17 @@  discard block
 block discarded – undo
1180 1234
 	private function setMemberLinks($fromLink, array $toMemberLinks)
1181 1235
 	{
1182 1236
 		// check you've been supplied with rinky dinky data
1183
-		if (!$this->isUUID($fromLink))
1184
-			throw new \InvalidArgumentException("The fromLink should be a UUID64. You passed in $fromLink");
1237
+		if (!$this->isUUID($fromLink)) {
1238
+					throw new \InvalidArgumentException("The fromLink should be a UUID64. You passed in $fromLink");
1239
+		}
1185 1240
 		$count = 0;
1186 1241
 		foreach ($toMemberLinks as $member => $toLinks) {
1187
-			if (!is_array($toLinks))
1188
-				$toLinks = [$toLinks];
1189
-			if (!$this->areUUIDs($toLinks))
1190
-				throw new \InvalidArgumentException("The toMemberLinks should be UUID64s. You passed in ".print_r($toLinks,true));
1242
+			if (!is_array($toLinks)) {
1243
+							$toLinks = [$toLinks];
1244
+			}
1245
+			if (!$this->areUUIDs($toLinks)) {
1246
+							throw new \InvalidArgumentException("The toMemberLinks should be UUID64s. You passed in ".print_r($toLinks,true));
1247
+			}
1191 1248
 			array_unique($toLinks);
1192 1249
 
1193 1250
 			//
@@ -1203,13 +1260,16 @@  discard block
 block discarded – undo
1203 1260
 			// add the new links in
1204 1261
 			$batchInsert = [];
1205 1262
 			$batchCount = count($toLinks);
1206
-			foreach ($toLinks as $toLink)
1207
-				$batchInsert[] = ['from_id'=>$fromLink, 'from_member'=>$member, 'to_id'=>$toLink];
1263
+			foreach ($toLinks as $toLink) {
1264
+							$batchInsert[] = ['from_id'=>$fromLink, 'from_member'=>$member, 'to_id'=>$toLink];
1265
+			}
1208 1266
 			$memberCount = 0;
1209
-			if (count($batchInsert))
1210
-				$memberCount = neon()->db->createCommand()->batchInsert('{{%dds_link}}', ['from_id','from_member','to_id'], $batchInsert)->execute();
1211
-			if (YII_DEBUG && $memberCount !== $batchCount)
1212
-				throw new Exception("The link insertion failed for member $member - $batchCount items should have been inserted vs $memberCount actual");
1267
+			if (count($batchInsert)) {
1268
+							$memberCount = neon()->db->createCommand()->batchInsert('{{%dds_link}}', ['from_id','from_member','to_id'], $batchInsert)->execute();
1269
+			}
1270
+			if (YII_DEBUG && $memberCount !== $batchCount) {
1271
+							throw new Exception("The link insertion failed for member $member - $batchCount items should have been inserted vs $memberCount actual");
1272
+			}
1213 1273
 			$count += $memberCount;
1214 1274
 		}
1215 1275
 		return $count;
@@ -1236,8 +1296,9 @@  discard block
 block discarded – undo
1236 1296
 	 */
1237 1297
 	protected function getMembersLinks(array $objectIds)
1238 1298
 	{
1239
-		if (empty($objectIds))
1240
-			return [];
1299
+		if (empty($objectIds)) {
1300
+					return [];
1301
+		}
1241 1302
 		$objectIds = array_unique($objectIds);
1242 1303
 		sort($objectIds, SORT_STRING);
1243 1304
 		$cacheKey = md5(serialize($objectIds));
@@ -1249,8 +1310,9 @@  discard block
 block discarded – undo
1249 1310
 				->asArray()
1250 1311
 				->all();
1251 1312
 			$multilinks = array_fill_keys($objectIds, []);
1252
-			foreach ($rows as $row)
1253
-				$multilinks[$row['from_id']][$row['from_member']][] = $row['to_id'];
1313
+			foreach ($rows as $row) {
1314
+							$multilinks[$row['from_id']][$row['from_member']][] = $row['to_id'];
1315
+			}
1254 1316
 			self::$_linkResultsCache[$cacheKey] = $multilinks;
1255 1317
 		}
1256 1318
 		return self::$_linkResultsCache[$cacheKey];
@@ -1267,8 +1329,9 @@  discard block
 block discarded – undo
1267 1329
 	private function createChangeLogEntry($class, $changeKey, $objectUuid, $originalValues=[], $newValues=[])
1268 1330
 	{
1269 1331
 		static $changeLog = null;
1270
-		if (!$changeLog)
1271
-			$changeLog = neon('dds')->IDdsChangeLogManagement;
1332
+		if (!$changeLog) {
1333
+					$changeLog = neon('dds')->IDdsChangeLogManagement;
1334
+		}
1272 1335
 		return $changeLog->addLogEntry($objectUuid, $class->toArray(), $changeKey, $originalValues, $newValues);
1273 1336
 	}
1274 1337
 
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/models/DdsDataType.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -18,59 +18,59 @@
 block discarded – undo
18 18
  */
19 19
 class DdsDataType extends \yii\db\ActiveRecord
20 20
 {
21
-    /**
22
-     * @inheritdoc
23
-     */
24
-    public static function tableName()
25
-    {
26
-        return 'dds_data_type';
27
-    }
21
+	/**
22
+	 * @inheritdoc
23
+	 */
24
+	public static function tableName()
25
+	{
26
+		return 'dds_data_type';
27
+	}
28 28
 
29
-    /**
30
-     * @inheritdoc
31
-     */
32
-    public function rules()
33
-    {
34
-        return [
35
-            [['data_type_ref', 'storage_ref'], 'required'],
36
-            [['deleted'], 'integer'],
37
-            [['data_type_ref', 'storage_ref'], 'string', 'max' => 50],
38
-            [['label'], 'string', 'max' => 300],
39
-            [['description'], 'string', 'max' => 1000],
40
-            [['definition'], 'string', 'max' => 2000],
41
-            [['data_type_ref'], 'unique'],
42
-            [['storage_ref'], 'exist', 'skipOnError' => true, 'targetClass' => DdsStorage::className(), 'targetAttribute' => ['storage_ref' => 'storage_ref']],
43
-        ];
44
-    }
29
+	/**
30
+	 * @inheritdoc
31
+	 */
32
+	public function rules()
33
+	{
34
+		return [
35
+			[['data_type_ref', 'storage_ref'], 'required'],
36
+			[['deleted'], 'integer'],
37
+			[['data_type_ref', 'storage_ref'], 'string', 'max' => 50],
38
+			[['label'], 'string', 'max' => 300],
39
+			[['description'], 'string', 'max' => 1000],
40
+			[['definition'], 'string', 'max' => 2000],
41
+			[['data_type_ref'], 'unique'],
42
+			[['storage_ref'], 'exist', 'skipOnError' => true, 'targetClass' => DdsStorage::className(), 'targetAttribute' => ['storage_ref' => 'storage_ref']],
43
+		];
44
+	}
45 45
 
46
-    /**
47
-     * @inheritdoc
48
-     */
49
-    public function attributeLabels()
50
-    {
51
-        return [
52
-            'data_type_ref' => 'Data Type Ref',
53
-            'label' => 'Label',
54
-            'description' => 'Description',
55
-            'definition' => 'Definition',
56
-            'storage_ref' => 'Storage Ref',
57
-            'deleted' => 'Deleted',
58
-        ];
59
-    }
46
+	/**
47
+	 * @inheritdoc
48
+	 */
49
+	public function attributeLabels()
50
+	{
51
+		return [
52
+			'data_type_ref' => 'Data Type Ref',
53
+			'label' => 'Label',
54
+			'description' => 'Description',
55
+			'definition' => 'Definition',
56
+			'storage_ref' => 'Storage Ref',
57
+			'deleted' => 'Deleted',
58
+		];
59
+	}
60 60
 
61
-    /**
62
-     * @return \yii\db\ActiveQuery
63
-     */
64
-    public function getStorageRef()
65
-    {
66
-        return $this->hasOne(DdsStorage::className(), ['storage_ref' => 'storage_ref']);
67
-    }
61
+	/**
62
+	 * @return \yii\db\ActiveQuery
63
+	 */
64
+	public function getStorageRef()
65
+	{
66
+		return $this->hasOne(DdsStorage::className(), ['storage_ref' => 'storage_ref']);
67
+	}
68 68
 
69
-    /**
70
-     * @return \yii\db\ActiveQuery
71
-     */
72
-    public function getDdsMembers()
73
-    {
74
-        return $this->hasMany(DdsMember::className(), ['data_type_ref' => 'data_type_ref']);
75
-    }
69
+	/**
70
+	 * @return \yii\db\ActiveQuery
71
+	 */
72
+	public function getDdsMembers()
73
+	{
74
+		return $this->hasMany(DdsMember::className(), ['data_type_ref' => 'data_type_ref']);
75
+	}
76 76
 }
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/models/DdsStorage.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,48 +15,48 @@
 block discarded – undo
15 15
  */
16 16
 class DdsStorage extends \yii\db\ActiveRecord
17 17
 {
18
-    /**
19
-     * @inheritdoc
20
-     */
21
-    public static function tableName()
22
-    {
23
-        return 'dds_storage';
24
-    }
18
+	/**
19
+	 * @inheritdoc
20
+	 */
21
+	public static function tableName()
22
+	{
23
+		return 'dds_storage';
24
+	}
25 25
 
26
-    /**
27
-     * @inheritdoc
28
-     */
29
-    public function rules()
30
-    {
31
-        return [
32
-            [['storage_ref', 'label', 'type', 'description'], 'required'],
33
-            [['type'], 'string'],
34
-            [['storage_ref'], 'string', 'max' => 50],
35
-            [['label'], 'string', 'max' => 300],
36
-            [['description'], 'string', 'max' => 8000],
37
-            [['storage_ref'], 'unique'],
38
-        ];
39
-    }
26
+	/**
27
+	 * @inheritdoc
28
+	 */
29
+	public function rules()
30
+	{
31
+		return [
32
+			[['storage_ref', 'label', 'type', 'description'], 'required'],
33
+			[['type'], 'string'],
34
+			[['storage_ref'], 'string', 'max' => 50],
35
+			[['label'], 'string', 'max' => 300],
36
+			[['description'], 'string', 'max' => 8000],
37
+			[['storage_ref'], 'unique'],
38
+		];
39
+	}
40 40
 
41
-    /**
42
-     * @inheritdoc
43
-     */
44
-    public function attributeLabels()
45
-    {
46
-        return [
47
-            'id' => 'ID',
48
-            'storage_ref' => 'Storage Ref',
49
-            'label' => 'Label',
50
-            'type' => 'Type',
51
-            'description' => 'Description',
52
-        ];
53
-    }
41
+	/**
42
+	 * @inheritdoc
43
+	 */
44
+	public function attributeLabels()
45
+	{
46
+		return [
47
+			'id' => 'ID',
48
+			'storage_ref' => 'Storage Ref',
49
+			'label' => 'Label',
50
+			'type' => 'Type',
51
+			'description' => 'Description',
52
+		];
53
+	}
54 54
 
55
-    /**
56
-     * @return \yii\db\ActiveQuery
57
-     */
58
-    public function getDdsDataTypes()
59
-    {
60
-        return $this->hasMany(DdsDataType::className(), ['storage_ref' => 'storage_ref']);
61
-    }
55
+	/**
56
+	 * @return \yii\db\ActiveQuery
57
+	 */
58
+	public function getDdsDataTypes()
59
+	{
60
+		return $this->hasMany(DdsDataType::className(), ['storage_ref' => 'storage_ref']);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/models/DdsClass.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@
 block discarded – undo
31 31
 	 */
32 32
 	public function hasChangeLog()
33 33
 	{
34
-		if (isset($this->attributes['change_log']))
35
-			return $this->attributes['change_log'];
34
+		if (isset($this->attributes['change_log'])) {
35
+					return $this->attributes['change_log'];
36
+		}
36 37
 		return false;
37 38
 	}
38 39
 
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/models/DdsMember.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 	{
87 87
 		// return choices as decoded json or null
88 88
 		if (!empty($this->choices))
89
-			$this->choices = json_decode($this->choices,true);
89
+			$this->choices = json_decode($this->choices, true);
90 90
 		parent::afterFind();
91 91
 	}
92 92
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,10 +72,11 @@  discard block
 block discarded – undo
72 72
 	public function beforeSave($insert)
73 73
 	{
74 74
 		// choices can only be an array and are stored as JSON
75
-		if (is_array($this->choices))
76
-			$this->choices = json_encode($this->choices);
77
-		else
78
-			$this->choices = null;
75
+		if (is_array($this->choices)) {
76
+					$this->choices = json_encode($this->choices);
77
+		} else {
78
+					$this->choices = null;
79
+		}
79 80
 		return parent::beforeSave($insert);
80 81
 	}
81 82
 
@@ -85,8 +86,9 @@  discard block
 block discarded – undo
85 86
 	public function afterFind()
86 87
 	{
87 88
 		// return choices as decoded json or null
88
-		if (!empty($this->choices))
89
-			$this->choices = json_decode($this->choices,true);
89
+		if (!empty($this->choices)) {
90
+					$this->choices = json_decode($this->choices,true);
91
+		}
90 92
 		parent::afterFind();
91 93
 	}
92 94
 
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/DdsCore.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$member = $storage[$memberRef];
112 112
 		// handle some storage differences
113 113
 		$columnCheck = substr($member['column'], 0, 4);
114
-		if ($columnCheck=='CHAR' || $columnCheck=='UUID') {
114
+		if ($columnCheck == 'CHAR' || $columnCheck == 'UUID') {
115 115
 			$size = (isset($member['definition']['size'])) ? $member['definition']['size'] : 150;
116 116
 			$member['column'] = str_replace($columnCheck, "CHAR($size)", $member['column']);
117 117
 		}
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 	 * @return []  array of ['member_ref']=>['data_type_ref', 'column', 'index']
161 161
 	 *  where column is the db column type
162 162
 	 */
163
-	protected function getMemberStorage($classType, $memberRef=null)
163
+	protected function getMemberStorage($classType, $memberRef = null)
164 164
 	{
165 165
 		$boundValues = [];
166
-		$query =<<<EOQ
166
+		$query = <<<EOQ
167 167
 SELECT `m`.`member_ref`, `s`.`type`, d.`definition` FROM dds_member m
168 168
 JOIN `dds_data_type` d ON `m`.`data_type_ref`=d.`data_type_ref`
169 169
 JOIN `dds_storage` s ON `d`.`storage_ref`=s.`storage_ref`
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			$memberStorage[$r['member_ref']] = [
183 183
 				'column' => $this->getColumnType($r['type']),
184 184
 				'index' => $this->getIndexType($r['type']),
185
-				'definition' => empty($r['definition']) ? null : json_decode($r['definition'],true)
185
+				'definition' => empty($r['definition']) ? null : json_decode($r['definition'], true)
186 186
 			];
187 187
 		}
188 188
 		return $memberStorage;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			case 'BINARY_LONG': $type = "LONGBLOB"; break;
210 210
 			case 'CHAR': $type = "CHAR"; break;
211 211
 			case 'UUID': $type = "UUID"; break;
212
-			default: $type="UNKNOWN STORAGE TYPE $storageType"; break;
212
+			default: $type = "UNKNOWN STORAGE TYPE $storageType"; break;
213 213
 		}
214 214
 		$collation = $this->getCollation($storageType);
215 215
 		if ($collation)
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @throws \InvalidArgumentException if class not found and $throwException is true
285 285
 	 * @return boolean  whether or not found
286 286
 	 */
287
-	protected function findClass($classType, &$class=null, $throwException=false)
287
+	protected function findClass($classType, &$class = null, $throwException = false)
288 288
 	{
289 289
 		$ct = $this->canonicaliseRef($classType);
290 290
 		if (empty(self::$_classCache[$ct])) {
@@ -333,13 +333,13 @@  discard block
 block discarded – undo
333 333
 	/**
334 334
 	 * @see IDdsClassManagement::listMembers
335 335
 	 */
336
-	protected function listMembersForClass($classType, $includeDeleted=false, $keyBy='member_ref')
336
+	protected function listMembersForClass($classType, $includeDeleted = false, $keyBy = 'member_ref')
337 337
 	{
338 338
 		if (!is_string($classType))
339 339
 			throw new \InvalidArgumentException('The class type $classType parameter should be a string');
340 340
 		$select = ['member_ref', 'label', 'data_type_ref', 'description', 'choices', 'map_field', 'link_class'];
341 341
 		if (!empty($keyBy) && !in_array($keyBy, $select))
342
-			throw new \InvalidArgumentException("Parameter keyBy must be empty or one of ".print_r($select,true));
342
+			throw new \InvalidArgumentException("Parameter keyBy must be empty or one of ".print_r($select, true));
343 343
 
344 344
 		// see if we have a cached version or getting from the database
345 345
 		if (empty(static::$_classMembersCache[$classType][$includeDeleted])) {
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	 */
391 391
 	protected function setClassMapMemberCache($classType, $member)
392 392
 	{
393
-		static::$_classMemberMapCache[$classType]=$member;
393
+		static::$_classMemberMapCache[$classType] = $member;
394 394
 	}
395 395
 
396 396
 	/**
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	 * @param \neon\daedalus\services\ddsManager\models\DdsDataType &$dataType
400 400
 	 * @return boolean  whether or not found
401 401
 	 */
402
-	protected function findDataType($dataTypeRef, &$dataType=null)
402
+	protected function findDataType($dataTypeRef, &$dataType = null)
403 403
 	{
404 404
 		$dataType = DdsDataType::findOne(['data_type_ref'=>$dataTypeRef]);
405 405
 		return ($dataType !== null);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 * @param char $separator  the single character separator to split the string into its parts
454 454
 	 * @return string  the canonicalised result
455 455
 	 */
456
-	protected function canonicaliseRefByParts($ref, $separator=".")
456
+	protected function canonicaliseRefByParts($ref, $separator = ".")
457 457
 	{
458 458
 		$parts = explode($separator, $ref);
459 459
 		$canons = [];
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @param $ref
468 468
 	 * @return string
469 469
 	 */
470
-	protected function quoteField($ref, $ddsObjectAlias='o')
470
+	protected function quoteField($ref, $ddsObjectAlias = 'o')
471 471
 	{
472 472
 		if (in_array($ref, ['_uuid', '_created', '_updated', '_class_ref'])) {
473 473
 			return "`$ddsObjectAlias`.`$ref`";
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		try {
488 488
 			$this->canonicaliseFiltersRecursive($filters);
489 489
 		} catch (\InvalidArgumentException $ex) {
490
-			throw new \InvalidArgumentException($ex->getMessage()." Filters passed in: ".print_r($filters,true));
490
+			throw new \InvalidArgumentException($ex->getMessage()." Filters passed in: ".print_r($filters, true));
491 491
 		}
492 492
 		return $filters;
493 493
 	}
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 	protected function canonicaliseFiltersRecursive(&$filters)
503 503
 	{
504 504
 		// is this a filter clause or set of filter clauses??
505
-		if (!is_array($filters) || count($filters)==0)
505
+		if (!is_array($filters) || count($filters) == 0)
506 506
 			return;
507 507
 
508 508
 		// recursively descend until one finds a filter clause
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 		}
514 514
 		// so canonicalise a filter clause
515 515
 		if (array_key_exists(0, $filters))
516
-			$this->canonicaliseFilter($filters[0],0);
516
+			$this->canonicaliseFilter($filters[0], 0);
517 517
 		if (array_key_exists(1, $filters))
518
-			$this->canonicaliseFilter($filters[1],1);
518
+			$this->canonicaliseFilter($filters[1], 1);
519 519
 	}
520 520
 
521 521
 	/**
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 		}
532 532
 		if ($key === 1) {
533 533
 			// accept only these operators
534
-			switch(strtolower($item)) {
534
+			switch (strtolower($item)) {
535 535
 				case '=': case '!=':
536 536
 				case '<': case '<=':
537 537
 				case '>': case '>=':
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	{
567 567
 		// check there are no integer keys as this means not all keys are in the logic
568 568
 		foreach ($keys as $k) {
569
-			if ((int)$k === $k) {
569
+			if ((int) $k === $k) {
570 570
 				throw new \InvalidArgumentException("Daedalus: You have provided a logic string to the query, but it looks like not all filter clauses have a logic name added to them. All filter clauses need to represented in the logic statement.");
571 571
 			}
572 572
 		}
@@ -577,8 +577,8 @@  discard block
 block discarded – undo
577 577
 			['AND', 'and', 'NOT', 'not', 'OR', 'or', ' ', ')', '('],
578 578
 			'', $subLogic
579 579
 		);
580
-		if (strlen($subLogic)>0)
581
-			throw new \InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true)." for a logic statement of ".print_r($logic,true)." The remaining characters are ".print_r($subLogic,true));
580
+		if (strlen($subLogic) > 0)
581
+			throw new \InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true)." for a logic statement of ".print_r($logic, true)." The remaining characters are ".print_r($subLogic, true));
582 582
 		return $logic;
583 583
 	}
584 584
 
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 				switch ($drn) {
615 615
 					case 'ASC': case 'DESC':
616 616
 						// allow -ve key starts for nulls last in MySql
617
-						if (strpos($k,'-') === 0)
617
+						if (strpos($k, '-') === 0)
618 618
 							$canon['-'.$this->quoteField($k)] = $drn;
619 619
 						else
620 620
 							$canon[$this->quoteField($k)] = $drn;
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 	protected function canonicaliseLimit($limit, &$total, &$calculateTotal)
639 639
 	{
640 640
 		$canon = [];
641
-		$total=null;
641
+		$total = null;
642 642
 		$calculateTotal = false;
643 643
 		if (is_array($limit)) {
644
-			$canon = ['start'=>0,'length'=>self::MAX_LENGTH];
644
+			$canon = ['start'=>0, 'length'=>self::MAX_LENGTH];
645 645
 			foreach ($limit as $k=>$v) {
646 646
 				$key = strtolower($k);
647 647
 				switch ($key) {
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 					case 'total':
655 655
 						// $v can be truthy or the previous integer
656 656
 						$total = is_numeric($v) ? (int) $v : null;
657
-						$calculateTotal = ($v===true || $v==='true');
657
+						$calculateTotal = ($v === true || $v === 'true');
658 658
 					break;
659 659
 				}
660 660
 			}
@@ -669,14 +669,14 @@  discard block
 block discarded – undo
669 669
 	 * @param [] $row  the row of data to be converted
670 670
 	 * @param string $classTypeKey the key in the data that will give the class type
671 671
 	 */
672
-	protected function convertFromDBToPHP(&$row, $links=[], $classTypeKey='_class_type')
672
+	protected function convertFromDBToPHP(&$row, $links = [], $classTypeKey = '_class_type')
673 673
 	{
674 674
 		$classType = $row[$classTypeKey];
675 675
 		$members = $this->getClassMembers($classType);
676 676
 		// now process only the member defined fields:
677 677
 		foreach ($row as $key => &$value) {
678 678
 			if (isset($members[$key])) {
679
-				$memberLinks = isset($links[$key])?$links[$key]:[];
679
+				$memberLinks = isset($links[$key]) ? $links[$key] : [];
680 680
 				$this->doConversionFromDBToPHP($members[$key], $value, $memberLinks);
681 681
 			}
682 682
 		}
@@ -688,9 +688,9 @@  discard block
 block discarded – undo
688 688
 	 * @param string $dataType the data type ref of the value
689 689
 	 * @param mixed $value  the value returned by the database
690 690
 	 */
691
-	protected function doConversionFromDBToPHP($member, &$value, $memberLinks=[])
691
+	protected function doConversionFromDBToPHP($member, &$value, $memberLinks = [])
692 692
 	{
693
-		switch($member['data_type_ref']) {
693
+		switch ($member['data_type_ref']) {
694 694
 			case 'choice':
695 695
 				// silently ignore deleted old choice as no longer valid
696 696
 				if (is_array($member['choices']) && isset($member['choices'][$value])) {
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	protected function doConversionFromPHPToDB($member, &$value, &$links)
754 754
 	{
755 755
 		$links = null;
756
-		switch($member['data_type_ref']) {
756
+		switch ($member['data_type_ref']) {
757 757
 			case 'choice':
758 758
 				// convert from the value array to the key if the array
759 759
 				// the array was returned
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 	 * @param array $dataTypes  add to restrict members to certain types
790 790
 	 * @return array the members
791 791
 	 */
792
-	protected function getClassMembers($classType, array $dataTypes=[])
792
+	protected function getClassMembers($classType, array $dataTypes = [])
793 793
 	{
794 794
 		static $_classMembers = [];
795 795
 		if (!array_key_exists($classType, $_classMembers)) {
@@ -868,11 +868,11 @@  discard block
 block discarded – undo
868 868
 		$fields = [];
869 869
 		$values = [];
870 870
 		foreach ($row as $f=>$v) {
871
-			$fields[]=$f;
871
+			$fields[] = $f;
872 872
 			$values[] = $this->pdoQuote($v);
873 873
 		}
874 874
 		if (count($fields))
875
-			return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(",",$values)).");";
875
+			return "REPLACE INTO `$table` (`".(implode('`,`', $fields)).'`) VALUES ('.(implode(",", $values)).");";
876 876
 		return null;
877 877
 	}
878 878
 
Please login to merge, or discard this patch.
Braces   +94 added lines, -64 removed lines patch added patch discarded remove patch
@@ -99,8 +99,9 @@  discard block
 block discarded – undo
99 99
 		$tableName = $this->getTableFromClassType($classType);
100 100
 		$upSql = $this->getDropTableSql($classType);
101 101
 		$downSql = $this->getCreateTableSql($tableName);
102
-		foreach ($upSql as $up)
103
-			neon()->db->createCommand($up)->execute();
102
+		foreach ($upSql as $up) {
103
+					neon()->db->createCommand($up)->execute();
104
+		}
104 105
 		$this->storeMigration($upSql, $downSql);
105 106
 	}
106 107
 
@@ -212,8 +213,9 @@  discard block
 block discarded – undo
212 213
 			default: $type="UNKNOWN STORAGE TYPE $storageType"; break;
213 214
 		}
214 215
 		$collation = $this->getCollation($storageType);
215
-		if ($collation)
216
-			return "$type $collation DEFAULT NULL ";
216
+		if ($collation) {
217
+					return "$type $collation DEFAULT NULL ";
218
+		}
217 219
 		return "$type DEFAULT NULL ";
218 220
 	}
219 221
 
@@ -291,8 +293,9 @@  discard block
 block discarded – undo
291 293
 			self::$_classCache[$ct] = DdsClass::findOne(['class_type' => $ct]);
292 294
 		}
293 295
 		$class = self::$_classCache[$ct];
294
-		if (!$class && $throwException)
295
-			throw new \InvalidArgumentException('Unknown class type "'.$ct.'"');
296
+		if (!$class && $throwException) {
297
+					throw new \InvalidArgumentException('Unknown class type "'.$ct.'"');
298
+		}
296 299
 		return ($class !== null);
297 300
 	}
298 301
 
@@ -335,32 +338,38 @@  discard block
 block discarded – undo
335 338
 	 */
336 339
 	protected function listMembersForClass($classType, $includeDeleted=false, $keyBy='member_ref')
337 340
 	{
338
-		if (!is_string($classType))
339
-			throw new \InvalidArgumentException('The class type $classType parameter should be a string');
341
+		if (!is_string($classType)) {
342
+					throw new \InvalidArgumentException('The class type $classType parameter should be a string');
343
+		}
340 344
 		$select = ['member_ref', 'label', 'data_type_ref', 'description', 'choices', 'map_field', 'link_class'];
341
-		if (!empty($keyBy) && !in_array($keyBy, $select))
342
-			throw new \InvalidArgumentException("Parameter keyBy must be empty or one of ".print_r($select,true));
345
+		if (!empty($keyBy) && !in_array($keyBy, $select)) {
346
+					throw new \InvalidArgumentException("Parameter keyBy must be empty or one of ".print_r($select,true));
347
+		}
343 348
 
344 349
 		// see if we have a cached version or getting from the database
345 350
 		if (empty(static::$_classMembersCache[$classType][$includeDeleted])) {
346 351
 			$query = DdsMember::find()->where(['class_type' => $classType]);
347
-			if ($includeDeleted)
348
-				$select[] = 'deleted';
349
-			else
350
-				$query->andWhere(['deleted' => 0]);
352
+			if ($includeDeleted) {
353
+							$select[] = 'deleted';
354
+			} else {
355
+							$query->andWhere(['deleted' => 0]);
356
+			}
351 357
 			$rows = $query->select($select)->orderBy('created')->asArray()->all();
352
-			foreach ($rows as $k=>$r)
353
-				$rows[$k]['choices'] = json_decode($r['choices'], true);
358
+			foreach ($rows as $k=>$r) {
359
+							$rows[$k]['choices'] = json_decode($r['choices'], true);
360
+			}
354 361
 			static::$_classMembersCache[$classType][$includeDeleted] = $rows;
355 362
 		}
356 363
 
357
-		if (empty($keyBy))
358
-			return static::$_classMembersCache[$classType][$includeDeleted];
364
+		if (empty($keyBy)) {
365
+					return static::$_classMembersCache[$classType][$includeDeleted];
366
+		}
359 367
 
360 368
 		// key by a particular ref
361 369
 		$results = [];
362
-		foreach (static::$_classMembersCache[$classType][$includeDeleted] as $r)
363
-			$results[$r[$keyBy]] = $r;
370
+		foreach (static::$_classMembersCache[$classType][$includeDeleted] as $r) {
371
+					$results[$r[$keyBy]] = $r;
372
+		}
364 373
 
365 374
 		return $results;
366 375
 	}
@@ -457,8 +466,9 @@  discard block
 block discarded – undo
457 466
 	{
458 467
 		$parts = explode($separator, $ref);
459 468
 		$canons = [];
460
-		foreach ($parts as $p)
461
-			$canons[] = $this->canonicaliseRef($p);
469
+		foreach ($parts as $p) {
470
+					$canons[] = $this->canonicaliseRef($p);
471
+		}
462 472
 		return implode($separator, $canons);
463 473
 	}
464 474
 
@@ -482,8 +492,9 @@  discard block
 block discarded – undo
482 492
 	 */
483 493
 	protected function canonicaliseFilters($filters)
484 494
 	{
485
-		if (!is_array($filters))
486
-			return [];
495
+		if (!is_array($filters)) {
496
+					return [];
497
+		}
487 498
 		try {
488 499
 			$this->canonicaliseFiltersRecursive($filters);
489 500
 		} catch (\InvalidArgumentException $ex) {
@@ -502,20 +513,24 @@  discard block
 block discarded – undo
502 513
 	protected function canonicaliseFiltersRecursive(&$filters)
503 514
 	{
504 515
 		// is this a filter clause or set of filter clauses??
505
-		if (!is_array($filters) || count($filters)==0)
506
-			return;
516
+		if (!is_array($filters) || count($filters)==0) {
517
+					return;
518
+		}
507 519
 
508 520
 		// recursively descend until one finds a filter clause
509 521
 		if (is_array($filters[0])) {
510
-			foreach ($filters as &$f)
511
-				$this->canonicaliseFiltersRecursive($f);
522
+			foreach ($filters as &$f) {
523
+							$this->canonicaliseFiltersRecursive($f);
524
+			}
512 525
 			return;
513 526
 		}
514 527
 		// so canonicalise a filter clause
515
-		if (array_key_exists(0, $filters))
516
-			$this->canonicaliseFilter($filters[0],0);
517
-		if (array_key_exists(1, $filters))
518
-			$this->canonicaliseFilter($filters[1],1);
528
+		if (array_key_exists(0, $filters)) {
529
+					$this->canonicaliseFilter($filters[0],0);
530
+		}
531
+		if (array_key_exists(1, $filters)) {
532
+					$this->canonicaliseFilter($filters[1],1);
533
+		}
519 534
 	}
520 535
 
521 536
 	/**
@@ -577,8 +592,9 @@  discard block
 block discarded – undo
577 592
 			['AND', 'and', 'NOT', 'not', 'OR', 'or', ' ', ')', '('],
578 593
 			'', $subLogic
579 594
 		);
580
-		if (strlen($subLogic)>0)
581
-			throw new \InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true)." for a logic statement of ".print_r($logic,true)." The remaining characters are ".print_r($subLogic,true));
595
+		if (strlen($subLogic)>0) {
596
+					throw new \InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true)." for a logic statement of ".print_r($logic,true)." The remaining characters are ".print_r($subLogic,true));
597
+		}
582 598
 		return $logic;
583 599
 	}
584 600
 
@@ -614,10 +630,11 @@  discard block
 block discarded – undo
614 630
 				switch ($drn) {
615 631
 					case 'ASC': case 'DESC':
616 632
 						// allow -ve key starts for nulls last in MySql
617
-						if (strpos($k,'-') === 0)
618
-							$canon['-'.$this->quoteField($k)] = $drn;
619
-						else
620
-							$canon[$this->quoteField($k)] = $drn;
633
+						if (strpos($k,'-') === 0) {
634
+													$canon['-'.$this->quoteField($k)] = $drn;
635
+						} else {
636
+													$canon[$this->quoteField($k)] = $drn;
637
+						}
621 638
 					break;
622 639
 					case 'RAND':
623 640
 						$canon['RAND'] = 'RAND';
@@ -705,14 +722,16 @@  discard block
 block discarded – undo
705 722
 				if (!empty($choices) && is_array($choices)) {
706 723
 					foreach ($choices as $choice) {
707 724
 						// silently ignore deleted old choice as no longer valid
708
-						if (isset($member['choices'][$choice]))
709
-							$value[] = ['key'=>$choice, 'value'=>$member['choices'][$choice]];
725
+						if (isset($member['choices'][$choice])) {
726
+													$value[] = ['key'=>$choice, 'value'=>$member['choices'][$choice]];
727
+						}
710 728
 					}
711 729
 				}
712 730
 			break;
713 731
 			case 'boolean':
714
-				if ($value === NULL)
715
-					return;
732
+				if ($value === NULL) {
733
+									return;
734
+				}
716 735
 				$value = !!$value;
717 736
 			break;
718 737
 			case 'json': $value = json_decode($value, true); break;
@@ -737,8 +756,9 @@  discard block
 block discarded – undo
737 756
 			$itemLinks = null;
738 757
 			if (isset($members[$key])) {
739 758
 				$this->doConversionFromPHPToDB($members[$key], $value, $itemLinks);
740
-				if ($itemLinks !== null)
741
-					$links[$key] = $itemLinks;
759
+				if ($itemLinks !== null) {
760
+									$links[$key] = $itemLinks;
761
+				}
742 762
 			}
743 763
 		}
744 764
 	}
@@ -757,16 +777,18 @@  discard block
 block discarded – undo
757 777
 			case 'choice':
758 778
 				// convert from the value array to the key if the array
759 779
 				// the array was returned
760
-				if (is_array($value) && isset($value['key']))
761
-					$value = $value['key'];
780
+				if (is_array($value) && isset($value['key'])) {
781
+									$value = $value['key'];
782
+				}
762 783
 			break;
763 784
 			case 'choice_multiple':
764 785
 				$value = json_encode($value);
765 786
 			break;
766 787
 			case 'boolean':
767 788
 				// check for null values
768
-				if ($value === null)
769
-					return;
789
+				if ($value === null) {
790
+									return;
791
+				}
770 792
 				// convert from truthy to database 1 or 0
771 793
 				$value = $value ? 1 : 0;
772 794
 			break;
@@ -798,19 +820,22 @@  discard block
 block discarded – undo
798 820
 				// make sure model afterFind has been run
799 821
 				$members = DdsMember::find()->where(['class_type'=>$classType])->all();
800 822
 				$membersByRef = [];
801
-				foreach ($members as $member)
802
-					$membersByRef[$member['member_ref']] = $member->attributes;
823
+				foreach ($members as $member) {
824
+									$membersByRef[$member['member_ref']] = $member->attributes;
825
+				}
803 826
 				$_classMembers[$classType] = $membersByRef;
804 827
 			} catch (\Exception $e) {
805 828
 				throw new \InvalidArgumentException("Error attempting to get members for $classType.");
806 829
 			}
807 830
 		}
808
-		if (empty($dataTypes))
809
-			return $_classMembers[$classType];
831
+		if (empty($dataTypes)) {
832
+					return $_classMembers[$classType];
833
+		}
810 834
 		$dataMembers = [];
811 835
 		foreach ($_classMembers[$classType] as $k=>$m) {
812
-			if (in_array($m['data_type_ref'], $dataTypes))
813
-				$dataMembers[$k] = $m;
836
+			if (in_array($m['data_type_ref'], $dataTypes)) {
837
+							$dataMembers[$k] = $m;
838
+			}
814 839
 		}
815 840
 		return $dataMembers;
816 841
 	}
@@ -863,16 +888,18 @@  discard block
 block discarded – undo
863 888
 	 */
864 889
 	protected function getTableRowReplaceSql($table, $row)
865 890
 	{
866
-		if (!is_array($row))
867
-			$row = $row->toArray();
891
+		if (!is_array($row)) {
892
+					$row = $row->toArray();
893
+		}
868 894
 		$fields = [];
869 895
 		$values = [];
870 896
 		foreach ($row as $f=>$v) {
871 897
 			$fields[]=$f;
872 898
 			$values[] = $this->pdoQuote($v);
873 899
 		}
874
-		if (count($fields))
875
-			return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(",",$values)).");";
900
+		if (count($fields)) {
901
+					return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(",",$values)).");";
902
+		}
876 903
 		return null;
877 904
 	}
878 905
 
@@ -883,10 +910,12 @@  discard block
 block discarded – undo
883 910
 	 */
884 911
 	private function pdoQuote($value)
885 912
 	{
886
-		if (is_array($value))
887
-			$value = json_encode($value);
888
-		if (is_null($value))
889
-			return 'null';
913
+		if (is_array($value)) {
914
+					$value = json_encode($value);
915
+		}
916
+		if (is_null($value)) {
917
+					return 'null';
918
+		}
890 919
 		return neon()->db->pdo->quote($value);
891 920
 	}
892 921
 
@@ -921,8 +950,9 @@  discard block
 block discarded – undo
921 950
 	protected function areUUIDs(array $candidates)
922 951
 	{
923 952
 		foreach ($candidates as $candidate) {
924
-			if (!$this->isUUID($candidate))
925
-				return false;
953
+			if (!$this->isUUID($candidate)) {
954
+							return false;
955
+			}
926 956
 		}
927 957
 		return true;
928 958
 	}
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/DdsDataDefinitionManager.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @param bool $includeDeleted
54 54
 	 * @return \yii\db\ActiveQuery
55 55
 	 */
56
-	public function countClasses($module=null, $includeDeleted=false)
56
+	public function countClasses($module = null, $includeDeleted = false)
57 57
 	{
58 58
 		$query = $this->_getClassesQuery($module, $includeDeleted);
59 59
 		return $query->count();
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	/**
63 63
 	 * @inheritdoc
64 64
 	 */
65
-	public function listClasses($module, &$total, $includeDeleted=false, $start=0, $length=100, $orderBy='label')
65
+	public function listClasses($module, &$total, $includeDeleted = false, $start = 0, $length = 100, $orderBy = 'label')
66 66
 	{
67 67
 		$query = $this->_getClassesQuery($module, $includeDeleted);
68 68
 		if ($start == 0)
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		$c->class_type = $classType;
123 123
 		$c->module = (empty($module) ? null : $module);
124 124
 		if (!$c->save())
125
-			throw new \RuntimeException("Couldn't save the class: ".print_r($c->errors,true));
125
+			throw new \RuntimeException("Couldn't save the class: ".print_r($c->errors, true));
126 126
 		$upSql = $this->getClassTypeMigrationSql($classType);
127 127
 		$downSql = "DELETE FROM `dds_class` WHERE `class_type`='$classType';";
128 128
 		$this->storeMigration($upSql, $downSql);
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	/**
134 134
 	 * @inheritdoc
135 135
 	 */
136
-	public function getClass($classType, $includeMembers=false)
136
+	public function getClass($classType, $includeMembers = false)
137 137
 	{
138 138
 		if ($this->findClass($classType, $class)) {
139 139
 			$data = $class->toArray();
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	public function editClass($classType, $changes)
151 151
 	{
152 152
 		$allowed = array_intersect_key($changes, array_flip(['label', 'description', 'module', 'change_log']));
153
-		if (count($allowed)==0)
153
+		if (count($allowed) == 0)
154 154
 			return;
155 155
 		$this->clearClassCache($classType);
156 156
 		$downSql = $this->getClassTypeMigrationSql($classType);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	/**
235 235
 	 * @inheritdoc
236 236
 	 */
237
-	public function listMembers($classType, $includeDeleted=false, $keyBy='member_ref')
237
+	public function listMembers($classType, $includeDeleted = false, $keyBy = 'member_ref')
238 238
 	{
239 239
 		return $this->listMembersForClass($classType, $includeDeleted, $keyBy);
240 240
 	}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	/**
243 243
 	 * @inheritdoc
244 244
 	 */
245
-	public function addMember($classType, &$memberRef, $dataTypeRef, $label, $description, $additional=null)
245
+	public function addMember($classType, &$memberRef, $dataTypeRef, $label, $description, $additional = null)
246 246
 	{
247 247
 		$classType = $this->canonicaliseRef($classType);
248 248
 		$memberRef = $this->canonicaliseRef($memberRef);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			// extract out any additional information
252 252
 			$choices = ((!empty($additional['choices']) && is_array($additional['choices'])) ? $additional['choices'] : []);
253 253
 			$linkClass = (!empty($additional['link_class']) ? $additional['link_class'] : null);
254
-			if (DdsMember::findOne(['class_type' => $classType, 'member_ref' => $memberRef])!==null)
254
+			if (DdsMember::findOne(['class_type' => $classType, 'member_ref' => $memberRef]) !== null)
255 255
 				throw new \InvalidArgumentException("The member $memberRef already exists");
256 256
 			if (in_array($dataTypeRef, ['link_uni', 'link_multi']) && !$linkClass) {
257 257
 				throw new \InvalidArgumentException("Link_uni, link_multi data types require a link_class to be passed for member '$classType::$memberRef'. You passed in ".print_r($additional, true));
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 			$mId = $this->storeMigration($upMember, $downMember);
276 276
 
277 277
 			// and create the member column
278
-			if (($error=$this->addClassMemberColumn($classType, $member->member_ref)) !== true) {
278
+			if (($error = $this->addClassMemberColumn($classType, $member->member_ref)) !== true) {
279 279
 				$member->delete();
280 280
 				$this->removeMigration($mId);
281 281
 				throw new \RuntimeException("Couldn't create the member column. Error=".$error);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	/**
289 289
 	 * @inheritdoc
290 290
 	 */
291
-	public function getMember($classType, $memberRef, $fields=[])
291
+	public function getMember($classType, $memberRef, $fields = [])
292 292
 	{
293 293
 		// !! keep member as an object so it runs all conversion code
294 294
 		$query = DdsMember::find();
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	{
311 311
 		// check that only allowed updates are made
312 312
 		$allowed = array_intersect_key($changes, array_flip(['label', 'description', 'definition', 'choices', 'link_class']));
313
-		if (count($allowed)==0)
313
+		if (count($allowed) == 0)
314 314
 			return;
315 315
 
316 316
 		// find the member and remove any illegitamate updates
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			$downSql = $this->getTableRowReplaceSql('dds_member', $member);
333 333
 			$member->attributes = $updates;
334 334
 			if (!$member->save())
335
-				throw new \RuntimeException("Couldn't update the member: ".print_r ($member->errors, true));
335
+				throw new \RuntimeException("Couldn't update the member: ".print_r($member->errors, true));
336 336
 			$upSql = $this->getTableRowReplaceSql('dds_member', $member);
337 337
 			$this->storeMigration($upSql, $downSql);
338 338
 			$this->clearClassMemberCache($classType);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	public function deleteMember($classType, $memberRef)
366 366
 	{
367 367
 		// delete a member if it isn't already deleted
368
-		if ($this->findMember($classType, $memberRef, $member) && $member->deleted==0) {
368
+		if ($this->findMember($classType, $memberRef, $member) && $member->deleted == 0) {
369 369
 			$upSql = "UPDATE `dds_member` SET `deleted`=1 WHERE `class_type`='$classType' AND `member_ref`='$memberRef';";
370 370
 			$downSql = "UPDATE `dds_member` SET `deleted`=0 WHERE `class_type`='$classType' AND `member_ref`='$memberRef';";
371 371
 			neon()->db->createCommand($upSql)->execute();
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	public function undeleteMember($classType, $memberRef)
381 381
 	{
382 382
 		// undelete a member if it is already deleted
383
-		if ($this->findMember($classType, $memberRef, $member) && $member->deleted==1) {
383
+		if ($this->findMember($classType, $memberRef, $member) && $member->deleted == 1) {
384 384
 			// create migrations
385 385
 			$upSql = "UPDATE `dds_member` SET `deleted`=0 WHERE `class_type`='$classType' AND `member_ref`='$memberRef';";
386 386
 			$downSql = "UPDATE `dds_member` SET `deleted`=1 WHERE `class_type`='$classType' AND `member_ref`='$memberRef';";
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	/**
428 428
 	 * @inheritdoc
429 429
 	 */
430
-	public function listDataTypes($includeDeleted=false)
430
+	public function listDataTypes($includeDeleted = false)
431 431
 	{
432 432
 		$query = DdsDataType::find();
433 433
 		$select = ['data_type_ref', 'label', 'description', 'definition', 'storage_ref'];
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 				$downSql = $this->getTableRowReplaceSql('dds_data_type', $dataType);
489 489
 				$dataType->attributes = $updates;
490 490
 				if (!$dataType->save())
491
-					throw new \RuntimeException("Couldn't save the datatype: ".print_r($dataType->errors(),true));
491
+					throw new \RuntimeException("Couldn't save the datatype: ".print_r($dataType->errors(), true));
492 492
 				$upSql = $this->getTableRowReplaceSql('dds_data_type', $dataType);
493 493
 				$this->storeMigration($upSql, $downSql);
494 494
 			}
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 					if (count($diff))
607 607
 						$diffs[$k] = $v;
608 608
 				} else {
609
-					if ((string)$v !== (string)$b[$k])
609
+					if ((string) $v !== (string) $b[$k])
610 610
 						$diffs[$k] = $v;
611 611
 				}
612 612
 			} else {
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	 */
624 624
 	private static $_classCache = [];
625 625
 
626
-	private function _getClassesQuery($module=null, $includeDeleted=false)
626
+	private function _getClassesQuery($module = null, $includeDeleted = false)
627 627
 	{
628 628
 		$query = DdsClass::find();
629 629
 		$select = ['class_type', 'label', 'description', 'module', 'count_total', 'count_deleted', 'change_log'];
Please login to merge, or discard this patch.
Braces   +84 added lines, -56 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function isMemberRefUnique($classType, $candidate)
41 41
 	{
42
-		if ($this->isClassTypeUnique($classType))
43
-			throw new \InvalidArgumentException("Class type ".$this->canonicaliseRef($classType)." unknown");
42
+		if ($this->isClassTypeUnique($classType)) {
43
+					throw new \InvalidArgumentException("Class type ".$this->canonicaliseRef($classType)." unknown");
44
+		}
44 45
 		$mr = $this->canonicaliseRef($candidate);
45 46
 		$member = DdsMember::find()->where(['class_type'=>$classType, 'member_ref'=>$mr])->one();
46 47
 		return ($member == null);
@@ -65,15 +66,17 @@  discard block
 block discarded – undo
65 66
 	public function listClasses($module, &$total, $includeDeleted=false, $start=0, $length=100, $orderBy='label')
66 67
 	{
67 68
 		$query = $this->_getClassesQuery($module, $includeDeleted);
68
-		if ($start == 0)
69
-			$total = (int) $query->count();
69
+		if ($start == 0) {
70
+					$total = (int) $query->count();
71
+		}
70 72
 		$results = $query->asArray()
71 73
 			->offset($start)
72 74
 			->limit($length)
73 75
 			->orderBy($orderBy)
74 76
 			->all();
75
-		foreach ($results as &$r)
76
-			$r['count_current'] = $r['count_total'] - $r['count_deleted'];
77
+		foreach ($results as &$r) {
78
+					$r['count_current'] = $r['count_total'] - $r['count_deleted'];
79
+		}
77 80
 		return $results;
78 81
 	}
79 82
 
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 			->asArray()
96 99
 			->all();
97 100
 		$map = [];
98
-		foreach ($mappable as $m)
99
-			$map[$m['class_type']] = $m['label'];
101
+		foreach ($mappable as $m) {
102
+					$map[$m['class_type']] = $m['label'];
103
+		}
100 104
 		return $map;
101 105
 	}
102 106
 
@@ -116,13 +120,15 @@  discard block
 block discarded – undo
116 120
 	public function addClass(&$classType, $module)
117 121
 	{
118 122
 		$classType = $this->canonicaliseRef($classType);
119
-		if (DdsClass::findOne(['class_type'=>$classType]) !== null)
120
-			throw new \InvalidArgumentException("The class $classType already exists");
123
+		if (DdsClass::findOne(['class_type'=>$classType]) !== null) {
124
+					throw new \InvalidArgumentException("The class $classType already exists");
125
+		}
121 126
 		$c = new DdsClass();
122 127
 		$c->class_type = $classType;
123 128
 		$c->module = (empty($module) ? null : $module);
124
-		if (!$c->save())
125
-			throw new \RuntimeException("Couldn't save the class: ".print_r($c->errors,true));
129
+		if (!$c->save()) {
130
+					throw new \RuntimeException("Couldn't save the class: ".print_r($c->errors,true));
131
+		}
126 132
 		$upSql = $this->getClassTypeMigrationSql($classType);
127 133
 		$downSql = "DELETE FROM `dds_class` WHERE `class_type`='$classType';";
128 134
 		$this->storeMigration($upSql, $downSql);
@@ -137,8 +143,9 @@  discard block
 block discarded – undo
137 143
 	{
138 144
 		if ($this->findClass($classType, $class)) {
139 145
 			$data = $class->toArray();
140
-			if ($includeMembers)
141
-				$data['members'] = $this->listMembers($class['class_type']);
146
+			if ($includeMembers) {
147
+							$data['members'] = $this->listMembers($class['class_type']);
148
+			}
142 149
 			return $data;
143 150
 		}
144 151
 		return null;
@@ -150,8 +157,9 @@  discard block
 block discarded – undo
150 157
 	public function editClass($classType, $changes)
151 158
 	{
152 159
 		$allowed = array_intersect_key($changes, array_flip(['label', 'description', 'module', 'change_log']));
153
-		if (count($allowed)==0)
154
-			return;
160
+		if (count($allowed)==0) {
161
+					return;
162
+		}
155 163
 		$this->clearClassCache($classType);
156 164
 		$downSql = $this->getClassTypeMigrationSql($classType);
157 165
 		if ($this->findClass($classType, $class)) {
@@ -159,8 +167,9 @@  discard block
 block discarded – undo
159 167
 			$updates = array_diff_assoc($allowed, $class->attributes);
160 168
 			if (count($updates)) {
161 169
 				$class->attributes = $updates;
162
-				if (!$class->save())
163
-					throw new \RuntimeException("Dds: Couldn't update the class '$classType': ".print_r($class->errors));
170
+				if (!$class->save()) {
171
+									throw new \RuntimeException("Dds: Couldn't update the class '$classType': ".print_r($class->errors));
172
+				}
164 173
 				$upSql = $this->getClassTypeMigrationSql($classType);
165 174
 				$this->storeMigration($upSql, $downSql);
166 175
 			}
@@ -203,8 +212,9 @@  discard block
 block discarded – undo
203 212
 	public function destroyClass($classType)
204 213
 	{
205 214
 		if ($this->findClass($classType, $class)) {
206
-			if ($this->hasObjects($classType))
207
-				throw new \RunTimeException("You need to delete all objects before you can destroy a class");
215
+			if ($this->hasObjects($classType)) {
216
+							throw new \RunTimeException("You need to delete all objects before you can destroy a class");
217
+			}
208 218
 
209 219
 			// now delete the rows
210 220
 			$members = DdsMember::find()->where(['class_type'=>$class->class_type])->asArray()->all();
@@ -216,12 +226,14 @@  discard block
 block discarded – undo
216 226
 					$errors[] = $e->getMessage();
217 227
 				}
218 228
 			}
219
-			if (count($errors))
220
-				throw new \RuntimeException("Couldn't destroy all of the members: ".print_r($errors, true));
229
+			if (count($errors)) {
230
+							throw new \RuntimeException("Couldn't destroy all of the members: ".print_r($errors, true));
231
+			}
221 232
 			// now delete the class
222 233
 			// can also return 0 - which is valid - false means there has been an error
223
-			if ($class->delete() === false)
224
-				throw new \RuntimeException("Couldn't destroy the class: ".print_r($class->errors, true));
234
+			if ($class->delete() === false) {
235
+							throw new \RuntimeException("Couldn't destroy the class: ".print_r($class->errors, true));
236
+			}
225 237
 			// and clear away the table
226 238
 			$this->dropClassTable($class->class_type);
227 239
 			$this->clearClassCache($classType);
@@ -251,8 +263,9 @@  discard block
 block discarded – undo
251 263
 			// extract out any additional information
252 264
 			$choices = ((!empty($additional['choices']) && is_array($additional['choices'])) ? $additional['choices'] : []);
253 265
 			$linkClass = (!empty($additional['link_class']) ? $additional['link_class'] : null);
254
-			if (DdsMember::findOne(['class_type' => $classType, 'member_ref' => $memberRef])!==null)
255
-				throw new \InvalidArgumentException("The member $memberRef already exists");
266
+			if (DdsMember::findOne(['class_type' => $classType, 'member_ref' => $memberRef])!==null) {
267
+							throw new \InvalidArgumentException("The member $memberRef already exists");
268
+			}
256 269
 			if (in_array($dataTypeRef, ['link_uni', 'link_multi']) && !$linkClass) {
257 270
 				throw new \InvalidArgumentException("Link_uni, link_multi data types require a link_class to be passed for member '$classType::$memberRef'. You passed in ".print_r($additional, true));
258 271
 			}
@@ -265,8 +278,9 @@  discard block
 block discarded – undo
265 278
 			$member->choices = ($this->memberAllowedChoices($dataTypeRef) ? $choices : null);
266 279
 			$member->link_class = ($this->memberAllowedLinks($dataTypeRef) ? $linkClass : null);
267 280
 			$member->created = $this->now();
268
-			if (!$member->save())
269
-				throw new \RuntimeException("Couldn't save the member: ".print_r($member->errors, true));
281
+			if (!$member->save()) {
282
+							throw new \RuntimeException("Couldn't save the member: ".print_r($member->errors, true));
283
+			}
270 284
 
271 285
 			// create the migrations
272 286
 			$savedMember = $this->getMember($classType, $memberRef);
@@ -310,12 +324,14 @@  discard block
 block discarded – undo
310 324
 	{
311 325
 		// check that only allowed updates are made
312 326
 		$allowed = array_intersect_key($changes, array_flip(['label', 'description', 'definition', 'choices', 'link_class']));
313
-		if (count($allowed)==0)
314
-			return;
327
+		if (count($allowed)==0) {
328
+					return;
329
+		}
315 330
 
316 331
 		// find the member and remove any illegitamate updates
317
-		if (!$this->findMember($classType, $memberRef, $member))
318
-			throw new \InvalidArgumentException("No member found");
332
+		if (!$this->findMember($classType, $memberRef, $member)) {
333
+					throw new \InvalidArgumentException("No member found");
334
+		}
319 335
 		if (isset($allowed['choices'])) {
320 336
 			$allowed['choices'] = empty($allowed['choices']) ? [] : $allowed['choices'];
321 337
 			if (!(is_array($allowed['choices']) && $this->memberAllowedChoices($member->data_type_ref))) {
@@ -323,16 +339,18 @@  discard block
 block discarded – undo
323 339
 			}
324 340
 		}
325 341
 
326
-		if (isset($allowed['link_class']) && !$this->memberAllowedLinks($member->data_type_ref))
327
-			unset($allowed['link_class']);
342
+		if (isset($allowed['link_class']) && !$this->memberAllowedLinks($member->data_type_ref)) {
343
+					unset($allowed['link_class']);
344
+		}
328 345
 
329 346
 		// finally check to see if there are any actual updates and if so save the provided updates
330 347
 		$updates = $this->getMemberUpdateDifferences($allowed, $member->attributes);
331 348
 		if (count($updates)) {
332 349
 			$downSql = $this->getTableRowReplaceSql('dds_member', $member);
333 350
 			$member->attributes = $updates;
334
-			if (!$member->save())
335
-				throw new \RuntimeException("Couldn't update the member: ".print_r ($member->errors, true));
351
+			if (!$member->save()) {
352
+							throw new \RuntimeException("Couldn't update the member: ".print_r ($member->errors, true));
353
+			}
336 354
 			$upSql = $this->getTableRowReplaceSql('dds_member', $member);
337 355
 			$this->storeMigration($upSql, $downSql);
338 356
 			$this->clearClassMemberCache($classType);
@@ -344,13 +362,15 @@  discard block
 block discarded – undo
344 362
 	 */
345 363
 	public function setMemberAsMapField($classType, $memberRef)
346 364
 	{
347
-		if (!$this->findMember($classType, $memberRef, $member))
348
-			throw new \InvalidArgumentException("No member found");
365
+		if (!$this->findMember($classType, $memberRef, $member)) {
366
+					throw new \InvalidArgumentException("No member found");
367
+		}
349 368
 
350 369
 		// find out which member had the map field set for migrations
351 370
 		$oldMember = DdsMember::findOne(['class_type'=>$classType, 'map_field'=>1]);
352
-		if ($oldMember && $oldMember->member_ref == $memberRef)
353
-			return;
371
+		if ($oldMember && $oldMember->member_ref == $memberRef) {
372
+					return;
373
+		}
354 374
 		$upSql = "UPDATE `dds_member` SET `map_field`=(IF (`member_ref`='$memberRef', 1, 0)) WHERE `class_type`='$classType';";
355 375
 		$downSql = ($oldMember ? "UPDATE `dds_member` SET `map_field`=(IF (`member_ref`='{$oldMember->member_ref}', 1, 0)) WHERE `class_type`='$classType';" : null);
356 376
 		neon()->db->createCommand($upSql)->execute();
@@ -445,16 +465,18 @@  discard block
 block discarded – undo
445 465
 	public function addDataType(&$dataTypeRef, $label, $description, $definition, $storageRef)
446 466
 	{
447 467
 		$dataTypeRef = $this->canonicaliseRef($dataTypeRef);
448
-		if ($this->findDataType($dataTypeRef))
449
-			throw new \InvalidArgumentException("The dataType $dataTypeRef already exists");
468
+		if ($this->findDataType($dataTypeRef)) {
469
+					throw new \InvalidArgumentException("The dataType $dataTypeRef already exists");
470
+		}
450 471
 		$dt = new DdsDataType();
451 472
 		$dt->data_type_ref = $dataTypeRef;
452 473
 		$dt->label = $label;
453 474
 		$dt->description = $description;
454 475
 		$dt->definition = $definition;
455 476
 		$dt->storage_ref = $storageRef;
456
-		if (!$dt->save())
457
-			throw new \RuntimeException("Couldn't create the datatype $dataTypeRef: ".print_r($dt->errors, true));
477
+		if (!$dt->save()) {
478
+					throw new \RuntimeException("Couldn't create the datatype $dataTypeRef: ".print_r($dt->errors, true));
479
+		}
458 480
 
459 481
 		// store the migration
460 482
 		$this->findDataType($dataTypeRef, $dt);
@@ -479,16 +501,18 @@  discard block
 block discarded – undo
479 501
 	public function editDataType($dataTypeRef, $changes)
480 502
 	{
481 503
 		$allowed = array_intersect_key($changes, array_flip(['label', 'description', 'definition']));
482
-		if (count($allowed) == 0)
483
-			return;
504
+		if (count($allowed) == 0) {
505
+					return;
506
+		}
484 507
 		if ($this->findDataType($dataTypeRef, $dataType)) {
485 508
 			// make the updates if there is anything to change
486 509
 			$updates = array_diff($allowed, $dataType->attributes);
487 510
 			if (count($updates)) {
488 511
 				$downSql = $this->getTableRowReplaceSql('dds_data_type', $dataType);
489 512
 				$dataType->attributes = $updates;
490
-				if (!$dataType->save())
491
-					throw new \RuntimeException("Couldn't save the datatype: ".print_r($dataType->errors(),true));
513
+				if (!$dataType->save()) {
514
+									throw new \RuntimeException("Couldn't save the datatype: ".print_r($dataType->errors(),true));
515
+				}
492 516
 				$upSql = $this->getTableRowReplaceSql('dds_data_type', $dataType);
493 517
 				$this->storeMigration($upSql, $downSql);
494 518
 			}
@@ -552,8 +576,9 @@  discard block
 block discarded – undo
552 576
 	private function getClassTypeMigrationSql($classType)
553 577
 	{
554 578
 		$ddsClass = DdsClass::findOne(['class_type'=>$classType]);
555
-		if ($ddsClass == null)
556
-			return null;
579
+		if ($ddsClass == null) {
580
+					return null;
581
+		}
557 582
 		return $this->getTableRowReplaceSql('dds_class', $ddsClass);
558 583
 	}
559 584
 
@@ -603,11 +628,13 @@  discard block
 block discarded – undo
603 628
 				if (is_array($v)) {
604 629
 					$diff = $this->getMemberUpdateDifferences($v, $b[$k]);
605 630
 					// we want all of the array if there were any differences
606
-					if (count($diff))
607
-						$diffs[$k] = $v;
631
+					if (count($diff)) {
632
+											$diffs[$k] = $v;
633
+					}
608 634
 				} else {
609
-					if ((string)$v !== (string)$b[$k])
610
-						$diffs[$k] = $v;
635
+					if ((string)$v !== (string)$b[$k]) {
636
+											$diffs[$k] = $v;
637
+					}
611 638
 				}
612 639
 			} else {
613 640
 				$diffs[$k] = $v;
@@ -633,8 +660,9 @@  discard block
 block discarded – undo
633 660
 			$query->andWhere(['deleted' => 0]);
634 661
 		}
635 662
 		$query->select($select);
636
-		if ($module != null)
637
-			$query->andWhere(['or', ['module' => $module], ['module' => NULL]]);
663
+		if ($module != null) {
664
+					$query->andWhere(['or', ['module' => $module], ['module' => NULL]]);
665
+		}
638 666
 		return $query;
639 667
 	}
640 668
 
Please login to merge, or discard this patch.
neon/daedalus/services/ddsHelpers/DdsQueryHelpers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 	/**
19 19
 	 * @inheritdoc
20 20
 	 */
21
-	public function addObjectDeletionChecksOnJoin(\yii\db\Query $query, $tables, $join='innerJoin')
21
+	public function addObjectDeletionChecksOnJoin(\yii\db\Query $query, $tables, $join = 'innerJoin')
22 22
 	{
23 23
 		foreach ($tables as $table) {
24 24
 			if ($join == 'innerJoin') {
Please login to merge, or discard this patch.