@@ -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 | |
@@ -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); |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | * создаем сущность |
| 28 | 28 | * |
| 29 | 29 | * @param array $row |
| 30 | - * @return type |
|
| 30 | + * @return \SimpleORM\EntityInterface |
|
| 31 | 31 | */ |
| 32 | 32 | public function createEntity(array $row) { |
| 33 | 33 | return $this->buildEntity(new City(), $row); |
@@ -22,6 +22,11 @@ discard block |
||
| 22 | 22 | protected $group; |
| 23 | 23 | protected $address; |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $name |
|
| 27 | + * @param string $email |
|
| 28 | + * @param string $password |
|
| 29 | + */ |
|
| 25 | 30 | function __construct($name, $email, $password, UserGroup $Group) { |
| 26 | 31 | $this->setName($name); |
| 27 | 32 | $this->setEmail($email); |
@@ -64,6 +69,9 @@ discard block |
||
| 64 | 69 | $this->password = $password; |
| 65 | 70 | } |
| 66 | 71 | |
| 72 | + /** |
|
| 73 | + * @param UserGroup $group |
|
| 74 | + */ |
|
| 67 | 75 | function setGroup($group) { |
| 68 | 76 | $this->group = $group; |
| 69 | 77 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | * создаем сущность |
| 28 | 28 | * |
| 29 | 29 | * @param array $row |
| 30 | - * @return type |
|
| 30 | + * @return \SimpleORM\EntityInterface |
|
| 31 | 31 | */ |
| 32 | 32 | public function createEntity(array $row) { |
| 33 | 33 | return $this->buildEntity(new UserAddress(), $row); |
@@ -18,6 +18,10 @@ |
||
| 18 | 18 | |
| 19 | 19 | protected $title; |
| 20 | 20 | |
| 21 | + /** |
|
| 22 | + * @param string $code |
|
| 23 | + * @param string $title |
|
| 24 | + */ |
|
| 21 | 25 | function __construct($code,$title){ |
| 22 | 26 | $this->setCode($code); |
| 23 | 27 | $this->setTitle($title); |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | /** |
| 304 | 304 | * Подготавливаем конечный вариант Сущности |
| 305 | 305 | * |
| 306 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 306 | + * @param EntityInterface $Entity |
|
| 307 | 307 | * @param array $row |
| 308 | - * @return \Core\Infrastructure\EntityInterface |
|
| 308 | + * @return EntityInterface |
|
| 309 | 309 | * @throws BadMethodCallException |
| 310 | 310 | */ |
| 311 | 311 | protected function buildEntity(EntityInterface $Entity, array $row){ |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * из объекта формирует массив |
| 358 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 358 | + * @param EntityInterface $Entity |
|
| 359 | 359 | * @return \Core\Infrastructure\EntityInterface |
| 360 | 360 | * @throws BadMethodCallException |
| 361 | 361 | */ |
@@ -400,6 +400,7 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | 402 | * Установка поля для маппинга |
| 403 | + * @param string $alias |
|
| 403 | 404 | */ |
| 404 | 405 | protected function addMappingField($alias,$field = null){ |
| 405 | 406 | |
@@ -162,13 +162,17 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function save(EntityInterface $Entity) |
| 164 | 164 | { |
| 165 | - if(method_exists($this, 'onAfterSave' )) $this->onAfterSave( $Entity ); |
|
| 165 | + if(method_exists($this, 'onAfterSave' )) { |
|
| 166 | + $this->onAfterSave( $Entity ); |
|
| 167 | + } |
|
| 166 | 168 | |
| 167 | 169 | if(!$this->saveWithoutEvents($Entity)){ |
| 168 | 170 | return false; |
| 169 | 171 | } |
| 170 | 172 | |
| 171 | - if(method_exists($this, 'onBeforeSave' )) $this->onBeforeSave( $Entity ); |
|
| 173 | + if(method_exists($this, 'onBeforeSave' )) { |
|
| 174 | + $this->onBeforeSave( $Entity ); |
|
| 175 | + } |
|
| 172 | 176 | |
| 173 | 177 | return true; |
| 174 | 178 | } |
@@ -247,8 +251,7 @@ discard block |
||
| 247 | 251 | if(count($rel['relations'])>0){ |
| 248 | 252 | $this->createListRelationReq($rel['relations'],$rel_list,$parent.'->get'.$rel['alias'].'()'); |
| 249 | 253 | $rel_list [$rel['name']]= $obj_parent_link.$obj_link; |
| 250 | - } |
|
| 251 | - else{ |
|
| 254 | + } else{ |
|
| 252 | 255 | $rel_list [$rel['name']] = $obj_parent_link.$obj_link; |
| 253 | 256 | } |
| 254 | 257 | } |
@@ -333,19 +336,18 @@ discard block |
||
| 333 | 336 | |
| 334 | 337 | if($this->use_joins===true || empty($row[$field])){ |
| 335 | 338 | $value = $mapper->createEntity($row); |
| 336 | - } |
|
| 337 | - else{ |
|
| 339 | + } else{ |
|
| 338 | 340 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
| 339 | 341 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
| 340 | 342 | } |
| 341 | 343 | |
| 342 | - } |
|
| 343 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 344 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 344 | 345 | $value = $row[strtolower($field)]; |
| 345 | 346 | } |
| 346 | 347 | |
| 347 | - if($value!==false) |
|
| 348 | - $Entity->{$method_set}($value); |
|
| 348 | + if($value!==false) { |
|
| 349 | + $Entity->{$method_set}($value); |
|
| 350 | + } |
|
| 349 | 351 | |
| 350 | 352 | } |
| 351 | 353 | |
@@ -376,18 +378,17 @@ discard block |
||
| 376 | 378 | //-------------------------------------------------------------------- |
| 377 | 379 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
| 378 | 380 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
| 379 | - } |
|
| 380 | - elseif(isset($cfg['relation'])){ |
|
| 381 | + } elseif(isset($cfg['relation'])){ |
|
| 381 | 382 | |
| 382 | - if(isset($cfg['on'])) |
|
| 383 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 384 | - else |
|
| 385 | - $fkey = 'id'; |
|
| 383 | + if(isset($cfg['on'])) { |
|
| 384 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 385 | + } else { |
|
| 386 | + $fkey = 'id'; |
|
| 387 | + } |
|
| 386 | 388 | |
| 387 | 389 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
| 388 | 390 | |
| 389 | - } |
|
| 390 | - else{ |
|
| 391 | + } else{ |
|
| 391 | 392 | $value = $Entity->{$method_get}(); |
| 392 | 393 | } |
| 393 | 394 | |
@@ -405,8 +406,7 @@ discard block |
||
| 405 | 406 | |
| 406 | 407 | if(is_string($field)){ |
| 407 | 408 | $field = ['field' => $field]; |
| 408 | - } |
|
| 409 | - elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 409 | + } elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 410 | 410 | $field['field'] = $alias; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -488,8 +488,7 @@ discard block |
||
| 488 | 488 | $delete_key > '' && |
| 489 | 489 | $Entity->getId() > 0){ |
| 490 | 490 | $result = $this->getAdapter()->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'"); |
| 491 | - } |
|
| 492 | - elseif($Entity->getId() > 0){ |
|
| 491 | + } elseif($Entity->getId() > 0){ |
|
| 493 | 492 | |
| 494 | 493 | if($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()." = ".$Entity->getId())){ |
| 495 | 494 | if(method_exists($this, 'onBeforeDelete' )){ $result = $this->onBeforeDelete( $Entity );} |
@@ -536,8 +535,9 @@ discard block |
||
| 536 | 535 | $this->use_delete === false && |
| 537 | 536 | $this->setSoftDeleteKey()>'' |
| 538 | 537 | && !isset($specification->getWhere()[$this->setSoftDeleteKey()]) |
| 539 | - ) |
|
| 540 | - $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 538 | + ) { |
|
| 539 | + $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 540 | + } |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |