@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function buildEntity(EntityInterface $Entity, array $row){ |
| 97 | 97 | |
| 98 | - foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 98 | + foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 99 | 99 | |
| 100 | 100 | $value = false; |
| 101 | 101 | |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | if($value!==false) |
| 133 | 133 | $Entity->{$method_set}($value); |
| 134 | 134 | |
| 135 | - } |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - return $Entity; |
|
| 137 | + return $Entity; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $row = []; |
| 150 | 150 | |
| 151 | - foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 151 | + foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 152 | 152 | |
| 153 | 153 | $field = $cfg['field']; |
| 154 | 154 | |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $row[$field] = $value; |
| 180 | 180 | |
| 181 | - } |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - return $row; |
|
| 183 | + return $row; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * Построение join-ов |
|
| 195 | - */ |
|
| 194 | + * Построение join-ов |
|
| 195 | + */ |
|
| 196 | 196 | protected function setRelations(ISpecificationCriteria $Specification){ |
| 197 | 197 | |
| 198 | 198 | $joins = []; |
@@ -44,8 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | if(is_string($field)){ |
| 46 | 46 | $field = ['field' => $field]; |
| 47 | - } |
|
| 48 | - elseif(is_array($field) && !isset($field['field'])){ |
|
| 47 | + } elseif(is_array($field) && !isset($field['field'])){ |
|
| 49 | 48 | $field['field'] = $alias; |
| 50 | 49 | } |
| 51 | 50 | |
@@ -118,19 +117,18 @@ discard block |
||
| 118 | 117 | |
| 119 | 118 | if($this->use_joins===true){ |
| 120 | 119 | $value = $mapper->createEntity($row); |
| 121 | - } |
|
| 122 | - else{ |
|
| 120 | + } else{ |
|
| 123 | 121 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
| 124 | 122 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
| 125 | 123 | } |
| 126 | 124 | |
| 127 | - } |
|
| 128 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 125 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 129 | 126 | $value = $row[strtolower($field)]; |
| 130 | 127 | } |
| 131 | 128 | |
| 132 | - if($value!==false) |
|
| 133 | - $Entity->{$method_set}($value); |
|
| 129 | + if($value!==false) { |
|
| 130 | + $Entity->{$method_set}($value); |
|
| 131 | + } |
|
| 134 | 132 | |
| 135 | 133 | } |
| 136 | 134 | |
@@ -161,18 +159,17 @@ discard block |
||
| 161 | 159 | //-------------------------------------------------------------------- |
| 162 | 160 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
| 163 | 161 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
| 164 | - } |
|
| 165 | - elseif(isset($cfg['relation'])){ |
|
| 162 | + } elseif(isset($cfg['relation'])){ |
|
| 166 | 163 | |
| 167 | - if(isset($cfg['on'])) |
|
| 168 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 169 | - else |
|
| 170 | - $fkey = 'id'; |
|
| 164 | + if(isset($cfg['on'])) { |
|
| 165 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 166 | + } else { |
|
| 167 | + $fkey = 'id'; |
|
| 168 | + } |
|
| 171 | 169 | |
| 172 | 170 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
| 173 | 171 | |
| 174 | - } |
|
| 175 | - else{ |
|
| 172 | + } else{ |
|
| 176 | 173 | $value = $Entity->{$method_get}(); |
| 177 | 174 | } |
| 178 | 175 | |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | interface EntityInterface |
| 10 | 10 | { |
| 11 | - //put your code here |
|
| 12 | - public function getId(); |
|
| 11 | + //put your code here |
|
| 12 | + public function getId(); |
|
| 13 | 13 | |
| 14 | - public function setId($id); |
|
| 14 | + public function setId($id); |
|
| 15 | 15 | |
| 16 | - public function getDeleted(); |
|
| 16 | + public function getDeleted(); |
|
| 17 | 17 | |
| 18 | - public function setDeleted($delete); |
|
| 18 | + public function setDeleted($delete); |
|
| 19 | 19 | } |