@@ -16,7 +16,9 @@ |
||
| 16 | 16 | if(!isset($this->owner->withList)){ |
| 17 | 17 | $this->owner->withList = []; |
| 18 | 18 | } |
| 19 | - if(!is_array($list)) $list = [$list]; |
|
| 19 | + if(!is_array($list)) { |
|
| 20 | + $list = [$list]; |
|
| 21 | + } |
|
| 20 | 22 | $list = array_map(function($e){return explode('.',$e); },$list); |
| 21 | 23 | $this->owner->withList = array_merge($this->owner->withList,$list); |
| 22 | 24 | return EagerLoadedDataList::cloneFrom($this->owner); |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | $export_eager = []; |
| 41 | 41 | foreach($export_fields as $field=>$_title) { |
| 42 | 42 | $parts = explode('.',$field); |
| 43 | - if(count($parts) < 2) continue; |
|
| 43 | + if(count($parts) < 2) { |
|
| 44 | + continue; |
|
| 45 | + } |
|
| 44 | 46 | $main = implode('.', array_slice($parts,0,-1)); |
| 45 | 47 | if(!in_array($main,$eager)){ |
| 46 | 48 | $eager[] = $main; |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | } |
| 49 | 51 | } |
| 50 | 52 | } |
| 51 | - if($eager) return $dataList->with($eager); |
|
| 53 | + if($eager) { |
|
| 54 | + return $dataList->with($eager); |
|
| 55 | + } |
|
| 52 | 56 | return $dataList; |
| 53 | 57 | } |
| 54 | 58 | } |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $result = []; |
| 54 | 54 | foreach($arr as $k => $v){ |
| 55 | - if(!isset($result[$v])) $result[$v] = []; |
|
| 55 | + if(!isset($result[$v])) { |
|
| 56 | + $result[$v] = []; |
|
| 57 | + } |
|
| 56 | 58 | $result[$v][] = $k; |
| 57 | 59 | } |
| 58 | 60 | return $result; |
@@ -76,7 +78,9 @@ discard block |
||
| 76 | 78 | private $relationsPrepared = false; |
| 77 | 79 | |
| 78 | 80 | public function prepareEagerRelations() { |
| 79 | - if($this->relationsPrepared) return; |
|
| 81 | + if($this->relationsPrepared) { |
|
| 82 | + return; |
|
| 83 | + } |
|
| 80 | 84 | $this->relationsPrepared = true; |
| 81 | 85 | $localClass = $this->dataClass(); |
| 82 | 86 | $config = Config::forClass($localClass); |
@@ -224,7 +228,9 @@ discard block |
||
| 224 | 228 | foreach($idsQuery as $row){ |
| 225 | 229 | $relID = $row[$component['childField']]; |
| 226 | 230 | $localID = $row[$component['parentField']]; |
| 227 | - if(!isset($collection[$localID])) $collection[$localID] = []; |
|
| 231 | + if(!isset($collection[$localID])) { |
|
| 232 | + $collection[$localID] = []; |
|
| 233 | + } |
|
| 228 | 234 | $collection[$localID][] = $relID; |
| 229 | 235 | $relListReverted[$relID] = 1;//use ids as keys to avoid |
| 230 | 236 | } |
@@ -326,13 +332,18 @@ discard block |
||
| 326 | 332 | |
| 327 | 333 | public static function EnsureArray($arr, $kfield = null) |
| 328 | 334 | { |
| 329 | - if(is_array($arr)) return $arr; |
|
| 335 | + if(is_array($arr)) { |
|
| 336 | + return $arr; |
|
| 337 | + } |
|
| 330 | 338 | $result = []; |
| 331 | 339 | foreach($arr as $k => $v){ |
| 332 | 340 | $key = $k; |
| 333 | 341 | if($kfield!==null) { |
| 334 | - if(is_array($v) && isset($v[$kfield])) $key = $v[$kfield]; |
|
| 335 | - elseif(is_object($v) && isset($v->$kfield)) $key = $v->$kfield; |
|
| 342 | + if(is_array($v) && isset($v[$kfield])) { |
|
| 343 | + $key = $v[$kfield]; |
|
| 344 | + } elseif(is_object($v) && isset($v->$kfield)) { |
|
| 345 | + $key = $v->$kfield; |
|
| 346 | + } |
|
| 336 | 347 | } |
| 337 | 348 | $result[$key] = $v; |
| 338 | 349 | } |