@@ -138,7 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | $data = $this->unbuildEntity($Entity); |
140 | 140 | |
141 | - if(method_exists($this, 'onPrepareData' )) $this->onPrepareData( $Entity , $data ); |
|
141 | + if(method_exists($this, 'onPrepareData' )) { |
|
142 | + $this->onPrepareData( $Entity , $data ); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | $id = $data[$this->getPrimaryKey()]; |
144 | 146 | unset($data[$this->getPrimaryKey()]); |
@@ -174,13 +176,17 @@ discard block |
||
174 | 176 | */ |
175 | 177 | public function save(EntityInterface $Entity) |
176 | 178 | { |
177 | - if(method_exists($this, 'onAfterSave' )) $this->onAfterSave( $Entity ); |
|
179 | + if(method_exists($this, 'onAfterSave' )) { |
|
180 | + $this->onAfterSave( $Entity ); |
|
181 | + } |
|
178 | 182 | |
179 | 183 | if(!$this->saveWithoutEvents($Entity)){ |
180 | 184 | return false; |
181 | 185 | } |
182 | 186 | |
183 | - if(method_exists($this, 'onBeforeSave' )) $this->onBeforeSave( $Entity ); |
|
187 | + if(method_exists($this, 'onBeforeSave' )) { |
|
188 | + $this->onBeforeSave( $Entity ); |
|
189 | + } |
|
184 | 190 | |
185 | 191 | return true; |
186 | 192 | } |
@@ -214,8 +220,7 @@ discard block |
||
214 | 220 | if(count($rel['relations'])>0){ |
215 | 221 | $this->createListRelationReq($rel['relations'],$rel_list,$obj_parent_link.'get'.$rel['alias'].'()'); |
216 | 222 | $rel_list [$obj_parent_link.$obj_link]= $rel['name']; |
217 | - } |
|
218 | - else{ |
|
223 | + } else{ |
|
219 | 224 | $rel_list [$obj_parent_link.$obj_link] = $rel['name']; |
220 | 225 | } |
221 | 226 | } |
@@ -295,19 +300,18 @@ discard block |
||
295 | 300 | // $value |
296 | 301 | // ]); |
297 | 302 | |
298 | - } |
|
299 | - else{ |
|
303 | + } else{ |
|
300 | 304 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
301 | 305 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
302 | 306 | } |
303 | 307 | |
304 | - } |
|
305 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
308 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
306 | 309 | $value = $row[strtolower($field)]; |
307 | 310 | } |
308 | 311 | |
309 | - if($value!==false) |
|
310 | - $Entity->{$method_set}($value); |
|
312 | + if($value!==false) { |
|
313 | + $Entity->{$method_set}($value); |
|
314 | + } |
|
311 | 315 | |
312 | 316 | } |
313 | 317 | |
@@ -345,18 +349,17 @@ discard block |
||
345 | 349 | //-------------------------------------------------------------------- |
346 | 350 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
347 | 351 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
348 | - } |
|
349 | - elseif(isset($cfg['relation']) && is_object($Entity->{$method_get}()) ){ |
|
352 | + } elseif(isset($cfg['relation']) && is_object($Entity->{$method_get}()) ){ |
|
350 | 353 | |
351 | - if(isset($cfg['on'])) |
|
352 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
353 | - else |
|
354 | - $fkey = 'id'; |
|
354 | + if(isset($cfg['on'])) { |
|
355 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
356 | + } else { |
|
357 | + $fkey = 'id'; |
|
358 | + } |
|
355 | 359 | |
356 | 360 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
357 | 361 | |
358 | - } |
|
359 | - else{ |
|
362 | + } else{ |
|
360 | 363 | $value = $Entity->{$method_get}(); |
361 | 364 | } |
362 | 365 | |
@@ -374,8 +377,7 @@ discard block |
||
374 | 377 | |
375 | 378 | if(is_string($field)){ |
376 | 379 | $field = ['field' => $field]; |
377 | - } |
|
378 | - elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
380 | + } elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
379 | 381 | $field['field'] = $alias; |
380 | 382 | } |
381 | 383 | |
@@ -475,8 +477,7 @@ discard block |
||
475 | 477 | $delete_key > '' && |
476 | 478 | $Entity->getId() > 0){ |
477 | 479 | $result = $this->getAdapter()->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'"); |
478 | - } |
|
479 | - elseif($Entity->getId() > 0){ |
|
480 | + } elseif($Entity->getId() > 0){ |
|
480 | 481 | |
481 | 482 | if($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()." = ".$Entity->getId())){ |
482 | 483 | if(method_exists($this, 'onBeforeDelete' )){ $result = $this->onBeforeDelete( $Entity );} |
@@ -527,8 +528,9 @@ discard block |
||
527 | 528 | $this->use_delete === false && |
528 | 529 | $this->setSoftDeleteKey()>'' |
529 | 530 | && !isset($specification->getWhere()[$this->setSoftDeleteKey()]) |
530 | - ) |
|
531 | - $specification->setWhere($this->setSoftDeleteKey(),0); |
|
531 | + ) { |
|
532 | + $specification->setWhere($this->setSoftDeleteKey(),0); |
|
533 | + } |
|
532 | 534 | } |
533 | 535 | |
534 | 536 | /** |