@@ -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 | } |
@@ -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 | |
@@ -156,6 +158,7 @@ discard block |
||
| 156 | 158 | /** |
| 157 | 159 | * Создает селект не только для основной таблицы но и для приджойненых таблиц |
| 158 | 160 | * @param type $joins |
| 161 | + * @param string $manualSelect |
|
| 159 | 162 | * @return type |
| 160 | 163 | */ |
| 161 | 164 | protected function createSelect(array $joins,$manualSelect) |
@@ -173,8 +176,8 @@ discard block |
||
| 173 | 176 | /** |
| 174 | 177 | * Получение записей по условию |
| 175 | 178 | * @param type $where |
| 176 | - * @param type $limit |
|
| 177 | - * @param type $offset |
|
| 179 | + * @param integer $limit |
|
| 180 | + * @param integer $offset |
|
| 178 | 181 | * @param type $joins |
| 179 | 182 | * @param type $order |
| 180 | 183 | * @param type $manualJoins |
@@ -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 | |
@@ -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 | } |
@@ -263,8 +268,7 @@ discard block |
||
| 263 | 268 | //автоопределени формата массива |
| 264 | 269 | if(isset($row[$this->key])){ |
| 265 | 270 | $field = $cfg['field']; |
| 266 | - } |
|
| 267 | - else{ |
|
| 271 | + } else{ |
|
| 268 | 272 | $field = $alias; |
| 269 | 273 | } |
| 270 | 274 | |
@@ -285,19 +289,18 @@ discard block |
||
| 285 | 289 | |
| 286 | 290 | if($this->use_joins===true || empty($row[$field])){ |
| 287 | 291 | $value = $mapper->createEntity($row); |
| 288 | - } |
|
| 289 | - else{ |
|
| 292 | + } else{ |
|
| 290 | 293 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
| 291 | 294 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
| 292 | 295 | } |
| 293 | 296 | |
| 294 | - } |
|
| 295 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 297 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 296 | 298 | $value = $row[strtolower($field)]; |
| 297 | 299 | } |
| 298 | 300 | |
| 299 | - if($value!==false) |
|
| 300 | - $Entity->{$method_set}($value); |
|
| 301 | + if($value!==false) { |
|
| 302 | + $Entity->{$method_set}($value); |
|
| 303 | + } |
|
| 301 | 304 | |
| 302 | 305 | } |
| 303 | 306 | |
@@ -328,18 +331,17 @@ discard block |
||
| 328 | 331 | //-------------------------------------------------------------------- |
| 329 | 332 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
| 330 | 333 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
| 331 | - } |
|
| 332 | - elseif(isset($cfg['relation']) && is_object($Entity->{$method_get}()) ){ |
|
| 334 | + } elseif(isset($cfg['relation']) && is_object($Entity->{$method_get}()) ){ |
|
| 333 | 335 | |
| 334 | - if(isset($cfg['on'])) |
|
| 335 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 336 | - else |
|
| 337 | - $fkey = 'id'; |
|
| 336 | + if(isset($cfg['on'])) { |
|
| 337 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 338 | + } else { |
|
| 339 | + $fkey = 'id'; |
|
| 340 | + } |
|
| 338 | 341 | |
| 339 | 342 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
| 340 | 343 | |
| 341 | - } |
|
| 342 | - else{ |
|
| 344 | + } else{ |
|
| 343 | 345 | $value = $Entity->{$method_get}(); |
| 344 | 346 | } |
| 345 | 347 | |
@@ -357,8 +359,7 @@ discard block |
||
| 357 | 359 | |
| 358 | 360 | if(is_string($field)){ |
| 359 | 361 | $field = ['field' => $field]; |
| 360 | - } |
|
| 361 | - elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 362 | + } elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 362 | 363 | $field['field'] = $alias; |
| 363 | 364 | } |
| 364 | 365 | |
@@ -458,8 +459,7 @@ discard block |
||
| 458 | 459 | $delete_key > '' && |
| 459 | 460 | $Entity->getId() > 0){ |
| 460 | 461 | $result = $this->getAdapter()->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'"); |
| 461 | - } |
|
| 462 | - elseif($Entity->getId() > 0){ |
|
| 462 | + } elseif($Entity->getId() > 0){ |
|
| 463 | 463 | |
| 464 | 464 | if($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()." = ".$Entity->getId())){ |
| 465 | 465 | if(method_exists($this, 'onBeforeDelete' )){ $result = $this->onBeforeDelete( $Entity );} |
@@ -510,8 +510,9 @@ discard block |
||
| 510 | 510 | $this->use_delete === false && |
| 511 | 511 | $this->setSoftDeleteKey()>'' |
| 512 | 512 | && !isset($specification->getWhere()[$this->setSoftDeleteKey()]) |
| 513 | - ) |
|
| 514 | - $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 513 | + ) { |
|
| 514 | + $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 515 | + } |
|
| 515 | 516 | } |
| 516 | 517 | |
| 517 | 518 | /** |
@@ -16,6 +16,9 @@ |
||
| 16 | 16 | |
| 17 | 17 | protected $name; |
| 18 | 18 | |
| 19 | + /** |
|
| 20 | + * @param string $name |
|
| 21 | + */ |
|
| 19 | 22 | function __construct($name) { |
| 20 | 23 | $this->setName($name); |
| 21 | 24 | } |
@@ -22,6 +22,11 @@ |
||
| 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); |
@@ -22,6 +22,10 @@ |
||
| 22 | 22 | |
| 23 | 23 | protected $city; |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $code |
|
| 27 | + * @param string $street |
|
| 28 | + */ |
|
| 25 | 29 | function __construct(City $City,$code,$street) { |
| 26 | 30 | $this->setCity($City); |
| 27 | 31 | $this->setCode($code); |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Перед сохранением извелкаем объект и дополняем массив для записи, недостающими полями |
| 19 | - * @param \Autoprice\Domain\Price\EntityInterface $Entity |
|
| 19 | + * @param EntityInterface $Entity |
|
| 20 | 20 | * @param type $data |
| 21 | 21 | */ |
| 22 | 22 | protected function onPrepareData(\SimpleORM\EntityInterface $Entity, &$data) { |
@@ -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 | } |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct($message, $code = null , $previous = null) { |
| 13 | 13 | |
| 14 | - if(is_array($message)) |
|
| 15 | - $message = implode('',$message); |
|
| 14 | + if(is_array($message)) { |
|
| 15 | + $message = implode('',$message); |
|
| 16 | + } |
|
| 16 | 17 | |
| 17 | 18 | parent::__construct($message, $code, $previous); |
| 18 | 19 | } |
@@ -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) |
@@ -19,8 +19,9 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Добавление значения в защищенное свойтсво |
| 22 | - * @param type $name |
|
| 23 | - * @param type $valued |
|
| 22 | + * @param string $name |
|
| 23 | + * @param type $value |
|
| 24 | + * @param SimpleORM\AbstractDataMapper $obj |
|
| 24 | 25 | */ |
| 25 | 26 | static public function setValueprotectedProperty($obj, $name, $value) |
| 26 | 27 | { |
@@ -30,6 +31,10 @@ discard block |
||
| 30 | 31 | $r->setValue($obj, $value); //изменяем значение |
| 31 | 32 | } |
| 32 | 33 | |
| 34 | + /** |
|
| 35 | + * @param SimpleORM\AbstractDataMapper $obj |
|
| 36 | + * @param string $name |
|
| 37 | + */ |
|
| 33 | 38 | static public function callMethod($obj, $name, array $args = []) { |
| 34 | 39 | $class = new \ReflectionClass($obj); |
| 35 | 40 | $method = $class->getMethod($name); |