@@ -80,8 +80,7 @@ |
||
80 | 80 | $o = $$_mc; |
81 | 81 | eval($set_path); |
82 | 82 | } |
83 | - } |
|
84 | - elseif(is_object($o) ){ |
|
83 | + } elseif(is_object($o) ){ |
|
85 | 84 | $$_mc = $o->{$_mc}(); |
86 | 85 | $o = $$_mc; |
87 | 86 | } |
@@ -132,7 +132,9 @@ discard block |
||
132 | 132 | |
133 | 133 | $data = $this->unbuildEntity($Entity); |
134 | 134 | |
135 | - if(method_exists($this, 'onPrepareData' )) $this->onPrepareData( $Entity , $data ); |
|
135 | + if(method_exists($this, 'onPrepareData' )) { |
|
136 | + $this->onPrepareData( $Entity , $data ); |
|
137 | + } |
|
136 | 138 | |
137 | 139 | $id = $data[$this->getPrimaryKey()]; |
138 | 140 | unset($data[$this->getPrimaryKey()]); |
@@ -168,13 +170,17 @@ discard block |
||
168 | 170 | */ |
169 | 171 | public function save(EntityInterface $Entity) |
170 | 172 | { |
171 | - if(method_exists($this, 'onAfterSave' )) $this->onAfterSave( $Entity ); |
|
173 | + if(method_exists($this, 'onAfterSave' )) { |
|
174 | + $this->onAfterSave( $Entity ); |
|
175 | + } |
|
172 | 176 | |
173 | 177 | if(!$this->saveWithoutEvents($Entity)){ |
174 | 178 | return false; |
175 | 179 | } |
176 | 180 | |
177 | - if(method_exists($this, 'onBeforeSave' )) $this->onBeforeSave( $Entity ); |
|
181 | + if(method_exists($this, 'onBeforeSave' )) { |
|
182 | + $this->onBeforeSave( $Entity ); |
|
183 | + } |
|
178 | 184 | |
179 | 185 | return true; |
180 | 186 | } |
@@ -208,8 +214,7 @@ discard block |
||
208 | 214 | if(count($rel['relations'])>0){ |
209 | 215 | $this->createListRelationReq($rel['relations'],$rel_list,$obj_parent_link.'get'.$rel['alias'].'()'); |
210 | 216 | $rel_list [$obj_parent_link.$obj_link]= $rel['name']; |
211 | - } |
|
212 | - else{ |
|
217 | + } else{ |
|
213 | 218 | $rel_list [$obj_parent_link.$obj_link] = $rel['name']; |
214 | 219 | } |
215 | 220 | } |
@@ -273,19 +278,18 @@ discard block |
||
273 | 278 | |
274 | 279 | if($this->use_joins===true || empty($row[$field])){ |
275 | 280 | $value = $mapper->createEntity($row); |
276 | - } |
|
277 | - else{ |
|
281 | + } else{ |
|
278 | 282 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
279 | 283 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
280 | 284 | } |
281 | 285 | |
282 | - } |
|
283 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
286 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
284 | 287 | $value = $row[strtolower($field)]; |
285 | 288 | } |
286 | 289 | |
287 | - if($value!==false) |
|
288 | - $Entity->{$method_set}($value); |
|
290 | + if($value!==false) { |
|
291 | + $Entity->{$method_set}($value); |
|
292 | + } |
|
289 | 293 | |
290 | 294 | } |
291 | 295 | |
@@ -316,18 +320,17 @@ discard block |
||
316 | 320 | //-------------------------------------------------------------------- |
317 | 321 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
318 | 322 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
319 | - } |
|
320 | - elseif(isset($cfg['relation']) && is_object($Entity->{$method_get}()) ){ |
|
323 | + } elseif(isset($cfg['relation']) && is_object($Entity->{$method_get}()) ){ |
|
321 | 324 | |
322 | - if(isset($cfg['on'])) |
|
323 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
324 | - else |
|
325 | - $fkey = 'id'; |
|
325 | + if(isset($cfg['on'])) { |
|
326 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
327 | + } else { |
|
328 | + $fkey = 'id'; |
|
329 | + } |
|
326 | 330 | |
327 | 331 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
328 | 332 | |
329 | - } |
|
330 | - else{ |
|
333 | + } else{ |
|
331 | 334 | $value = $Entity->{$method_get}(); |
332 | 335 | } |
333 | 336 | |
@@ -345,8 +348,7 @@ discard block |
||
345 | 348 | |
346 | 349 | if(is_string($field)){ |
347 | 350 | $field = ['field' => $field]; |
348 | - } |
|
349 | - elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
351 | + } elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
350 | 352 | $field['field'] = $alias; |
351 | 353 | } |
352 | 354 | |
@@ -428,8 +430,7 @@ discard block |
||
428 | 430 | $delete_key > '' && |
429 | 431 | $Entity->getId() > 0){ |
430 | 432 | $result = $this->getAdapter()->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'"); |
431 | - } |
|
432 | - elseif($Entity->getId() > 0){ |
|
433 | + } elseif($Entity->getId() > 0){ |
|
433 | 434 | |
434 | 435 | if($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()." = ".$Entity->getId())){ |
435 | 436 | if(method_exists($this, 'onBeforeDelete' )){ $result = $this->onBeforeDelete( $Entity );} |
@@ -476,8 +477,9 @@ discard block |
||
476 | 477 | $this->use_delete === false && |
477 | 478 | $this->setSoftDeleteKey()>'' |
478 | 479 | && !isset($specification->getWhere()[$this->setSoftDeleteKey()]) |
479 | - ) |
|
480 | - $specification->setWhere($this->setSoftDeleteKey(),0); |
|
480 | + ) { |
|
481 | + $specification->setWhere($this->setSoftDeleteKey(),0); |
|
482 | + } |
|
481 | 483 | } |
482 | 484 | |
483 | 485 | /** |