@@ -77,8 +77,7 @@ |
||
| 77 | 77 | { |
| 78 | 78 | if($value!==false){ |
| 79 | 79 | $this->where[$field] = $value; |
| 80 | - } |
|
| 81 | - else{ |
|
| 80 | + } else{ |
|
| 82 | 81 | $this->where = $where; |
| 83 | 82 | } |
| 84 | 83 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * Подготавливаем конечный вариант Сущности |
| 81 | 81 | * |
| 82 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 82 | + * @param EntityInterface $Entity |
|
| 83 | 83 | * @param array $row |
| 84 | - * @return \Core\Infrastructure\EntityInterface |
|
| 84 | + * @return EntityInterface |
|
| 85 | 85 | * @throws BadMethodCallException |
| 86 | 86 | */ |
| 87 | 87 | protected function buildEntity(EntityInterface $Entity, array $row){ |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * из объекта формирует массив |
| 134 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 134 | + * @param EntityInterface $Entity |
|
| 135 | 135 | * @return \Core\Infrastructure\EntityInterface |
| 136 | 136 | * @throws BadMethodCallException |
| 137 | 137 | */ |
@@ -126,7 +126,9 @@ discard block |
||
| 126 | 126 | $data = $this->unbuildEntity($Entity); |
| 127 | 127 | |
| 128 | 128 | //protected function onAfterSave(\SimpleORM\EntityInterface $Entity, &$data) |
| 129 | - if(method_exists($this, 'onAfterSave' )) $this->onAfterSave( $Entity, $data ); |
|
| 129 | + if(method_exists($this, 'onAfterSave' )) { |
|
| 130 | + $this->onAfterSave( $Entity, $data ); |
|
| 131 | + } |
|
| 130 | 132 | |
| 131 | 133 | $id = $data[$this->getPrimaryKey()]; |
| 132 | 134 | unset($data[$this->getPrimaryKey()]); |
@@ -153,7 +155,9 @@ discard block |
||
| 153 | 155 | |
| 154 | 156 | } |
| 155 | 157 | |
| 156 | - if(method_exists($this, 'onBeforeSave' )) $this->onBeforeSave( $Entity ); |
|
| 158 | + if(method_exists($this, 'onBeforeSave' )) { |
|
| 159 | + $this->onBeforeSave( $Entity ); |
|
| 160 | + } |
|
| 157 | 161 | |
| 158 | 162 | |
| 159 | 163 | return true; |
@@ -233,19 +237,18 @@ discard block |
||
| 233 | 237 | |
| 234 | 238 | if($this->use_joins===true){ |
| 235 | 239 | $value = $mapper->createEntity($row); |
| 236 | - } |
|
| 237 | - else{ |
|
| 240 | + } else{ |
|
| 238 | 241 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
| 239 | 242 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
| 240 | 243 | } |
| 241 | 244 | |
| 242 | - } |
|
| 243 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 245 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 244 | 246 | $value = $row[strtolower($field)]; |
| 245 | 247 | } |
| 246 | 248 | |
| 247 | - if($value!==false) |
|
| 248 | - $Entity->{$method_set}($value); |
|
| 249 | + if($value!==false) { |
|
| 250 | + $Entity->{$method_set}($value); |
|
| 251 | + } |
|
| 249 | 252 | |
| 250 | 253 | } |
| 251 | 254 | |
@@ -276,18 +279,17 @@ discard block |
||
| 276 | 279 | //-------------------------------------------------------------------- |
| 277 | 280 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
| 278 | 281 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
| 279 | - } |
|
| 280 | - elseif(isset($cfg['relation'])){ |
|
| 282 | + } elseif(isset($cfg['relation'])){ |
|
| 281 | 283 | |
| 282 | - if(isset($cfg['on'])) |
|
| 283 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 284 | - else |
|
| 285 | - $fkey = 'id'; |
|
| 284 | + if(isset($cfg['on'])) { |
|
| 285 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 286 | + } else { |
|
| 287 | + $fkey = 'id'; |
|
| 288 | + } |
|
| 286 | 289 | |
| 287 | 290 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
| 288 | 291 | |
| 289 | - } |
|
| 290 | - else{ |
|
| 292 | + } else{ |
|
| 291 | 293 | $value = $Entity->{$method_get}(); |
| 292 | 294 | } |
| 293 | 295 | |
@@ -305,8 +307,7 @@ discard block |
||
| 305 | 307 | |
| 306 | 308 | if(is_string($field)){ |
| 307 | 309 | $field = ['field' => $field]; |
| 308 | - } |
|
| 309 | - elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 310 | + } elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 310 | 311 | $field['field'] = $alias; |
| 311 | 312 | } |
| 312 | 313 | |
@@ -388,8 +389,7 @@ discard block |
||
| 388 | 389 | $delete_key > '' && |
| 389 | 390 | $Entity->getId() > 0){ |
| 390 | 391 | $result = $this->getAdapter()->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'"); |
| 391 | - } |
|
| 392 | - elseif($Entity->getId() > 0){ |
|
| 392 | + } elseif($Entity->getId() > 0){ |
|
| 393 | 393 | |
| 394 | 394 | if($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()." = ".$Entity->getId())){ |
| 395 | 395 | if(method_exists($this, 'onBeforeDelete' )){ $result = $this->onBeforeDelete( $Entity );} |
@@ -436,8 +436,9 @@ discard block |
||
| 436 | 436 | $this->use_delete === false && |
| 437 | 437 | $this->setSoftDeleteKey()>'' |
| 438 | 438 | && !isset($specification->getWhere()[$this->setSoftDeleteKey()]) |
| 439 | - ) |
|
| 440 | - $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 439 | + ) { |
|
| 440 | + $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 441 | + } |
|
| 441 | 442 | } |
| 442 | 443 | |
| 443 | 444 | /** |
@@ -66,6 +66,9 @@ discard block |
||
| 66 | 66 | return $this->adapter->delete($table,$where); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | + /** |
|
| 70 | + * @param string $str |
|
| 71 | + */ |
|
| 69 | 72 | protected function escape_str($str, $like = FALSE) |
| 70 | 73 | { |
| 71 | 74 | |
@@ -120,7 +123,6 @@ discard block |
||
| 120 | 123 | |
| 121 | 124 | /** |
| 122 | 125 | * |
| 123 | - * @param type $param |
|
| 124 | 126 | */ |
| 125 | 127 | public function getResultQuery($table,\SimpleORM\ISpecificationCriteria $Criteria ) { |
| 126 | 128 | |
@@ -155,7 +157,7 @@ discard block |
||
| 155 | 157 | /** |
| 156 | 158 | * Создает селект не только для основной таблицы но и для приджойненых таблиц |
| 157 | 159 | * @param type $joins |
| 158 | - * @return type |
|
| 160 | + * @return string |
|
| 159 | 161 | */ |
| 160 | 162 | protected function createSelect($joins) |
| 161 | 163 | { |
@@ -171,8 +173,8 @@ discard block |
||
| 171 | 173 | /** |
| 172 | 174 | * Получение записей по условию |
| 173 | 175 | * @param type $where |
| 174 | - * @param type $limit |
|
| 175 | - * @param type $offset |
|
| 176 | + * @param integer $limit |
|
| 177 | + * @param integer $offset |
|
| 176 | 178 | * @param type $joins |
| 177 | 179 | * @param type $order |
| 178 | 180 | * @param type $manualJoins |
@@ -71,8 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | if(!$like){ |
| 73 | 73 | return $this->adapter->escape_str($str); |
| 74 | - } |
|
| 75 | - else{ |
|
| 74 | + } else{ |
|
| 76 | 75 | return $this->adapter->escape_like_str($str); |
| 77 | 76 | } |
| 78 | 77 | |
@@ -145,8 +144,7 @@ discard block |
||
| 145 | 144 | if(preg_match('~(.*?)\.(.*?)$~is',$table,$m)){ |
| 146 | 145 | $this->database = $m[1]; |
| 147 | 146 | $this->TableName = $m[2]; |
| 148 | - } |
|
| 149 | - else{ |
|
| 147 | + } else{ |
|
| 150 | 148 | $this->TableName = $table; |
| 151 | 149 | } |
| 152 | 150 | } |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * получение защищенного свойства |
| 8 | - * @param type $o |
|
| 9 | - * @param type $name |
|
| 8 | + * @param string $name |
|
| 9 | + * @param SimpleORM\AbstractDataMapper $obj |
|
| 10 | 10 | * @return type |
| 11 | 11 | */ |
| 12 | 12 | static public function getProtectedAttribute($obj, $name) |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * Добавление значения в защищенное свойтсво |
| 22 | 22 | * @param type $name |
| 23 | - * @param type $valued |
|
| 23 | + * @param type $value |
|
| 24 | 24 | */ |
| 25 | 25 | private function setValueprotectedProperty($name, $value) |
| 26 | 26 | { |
@@ -30,6 +30,10 @@ discard block |
||
| 30 | 30 | $r->setValue($this->object, $value); //изменяем значение |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param SimpleORM\AbstractDataMapper $obj |
|
| 35 | + * @param string $name |
|
| 36 | + */ |
|
| 33 | 37 | static public function callMethod($obj, $name, array $args) { |
| 34 | 38 | $class = new \ReflectionClass($obj); |
| 35 | 39 | $method = $class->getMethod($name); |