@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Cохранение сущности |
| 56 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 56 | + * @param EntityInterface $Entity |
|
| 57 | 57 | */ |
| 58 | 58 | public function save(EntityInterface $Entity) |
| 59 | 59 | { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * из объекта формирует массив |
| 95 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 95 | + * @param EntityInterface $Entity |
|
| 96 | 96 | * @return \Core\Infrastructure\EntityInterface |
| 97 | 97 | * @throws BadMethodCallException |
| 98 | 98 | */ |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * Подготавливаем конечный вариант Сущности |
| 128 | 128 | * |
| 129 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 129 | + * @param EntityInterface $Entity |
|
| 130 | 130 | * @param array $row |
| 131 | - * @return \Core\Infrastructure\EntityInterface |
|
| 131 | + * @return EntityInterface |
|
| 132 | 132 | * @throws BadMethodCallException |
| 133 | 133 | */ |
| 134 | 134 | protected function buildEntity(EntityInterface $Entity, array $row){ |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | 174 | * |
| 175 | - * @param \Core\Infrastructure\ISpecificationCriteria $specification |
|
| 175 | + * @param ISpecificationCriteria $specification |
|
| 176 | 176 | * @return type |
| 177 | 177 | */ |
| 178 | 178 | public function findBySpecification(ISpecificationCriteria $specification){ |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * Удаление записи |
| 198 | - * @param \Core\Infrastructure\EntityInterface $Entity |
|
| 198 | + * @param EntityInterface $Entity |
|
| 199 | 199 | * @return boolean |
| 200 | 200 | */ |
| 201 | 201 | public function delete(EntityInterface $Entity) |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | /** |
| 251 | 251 | * Выборка удаленных моделей |
| 252 | - * @param \Core\Infrastructure\ISpecificationCriteria $specification |
|
| 252 | + * @param ISpecificationCriteria $specification |
|
| 253 | 253 | */ |
| 254 | 254 | private function setSoftDelete(ISpecificationCriteria $specification){ |
| 255 | 255 | if( |
@@ -110,8 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | if(method_exists($this, 'onUnBuild'.$propery )){ |
| 112 | 112 | $value = $this->{'onUnBuild'.$propery}( $Entity->{$method_get}() ); |
| 113 | - } |
|
| 114 | - else{ |
|
| 113 | + } else{ |
|
| 115 | 114 | $value = $Entity->{$method_get}(); |
| 116 | 115 | } |
| 117 | 116 | $row[$field] = $value; |
@@ -146,13 +145,13 @@ discard block |
||
| 146 | 145 | //событие onBuildField |
| 147 | 146 | if(method_exists($this, 'onBuild'.$propery )){ |
| 148 | 147 | $value = $this->{'onBuild'.$propery}($field,$row); |
| 149 | - } |
|
| 150 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 148 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 151 | 149 | $value = $row[strtolower($field)]; |
| 152 | 150 | } |
| 153 | 151 | |
| 154 | - if($value!==false) |
|
| 155 | - $Entity->{$method_set}($value); |
|
| 152 | + if($value!==false) { |
|
| 153 | + $Entity->{$method_set}($value); |
|
| 154 | + } |
|
| 156 | 155 | |
| 157 | 156 | } |
| 158 | 157 | |
@@ -206,8 +205,7 @@ discard block |
||
| 206 | 205 | $delete_key > '' && |
| 207 | 206 | $Entity->getId() > 0){ |
| 208 | 207 | $result = $this->db->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'"); |
| 209 | - } |
|
| 210 | - elseif($Entity->getId() > 0){ |
|
| 208 | + } elseif($Entity->getId() > 0){ |
|
| 211 | 209 | |
| 212 | 210 | if($result = $this->db->delete($this->getEntityTable(), $this->getPrimaryKey()." = ".$Entity->getId())){ |
| 213 | 211 | if(method_exists($this, 'onDeleteSuccess' )){ $result = $this->onDeleteSuccess( $Entity );} |
@@ -253,8 +251,9 @@ discard block |
||
| 253 | 251 | if( |
| 254 | 252 | $this->setSoftDeleteKey()>'' |
| 255 | 253 | && !isset($specification->getWhere()[$this->setSoftDeleteKey()]) |
| 256 | - ) |
|
| 257 | - $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 254 | + ) { |
|
| 255 | + $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 256 | + } |
|
| 258 | 257 | } |
| 259 | 258 | |
| 260 | 259 | /** |
@@ -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 | */ |
@@ -44,8 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | if(is_string($field)){ |
| 46 | 46 | $field = ['field' => $field]; |
| 47 | - } |
|
| 48 | - elseif(is_array($field) && !isset($field['field'])){ |
|
| 47 | + } elseif(is_array($field) && !isset($field['field'])){ |
|
| 49 | 48 | $field['field'] = $alias; |
| 50 | 49 | } |
| 51 | 50 | |
@@ -118,19 +117,18 @@ discard block |
||
| 118 | 117 | |
| 119 | 118 | if($this->use_joins===true){ |
| 120 | 119 | $value = $mapper->createEntity($row); |
| 121 | - } |
|
| 122 | - else{ |
|
| 120 | + } else{ |
|
| 123 | 121 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
| 124 | 122 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
| 125 | 123 | } |
| 126 | 124 | |
| 127 | - } |
|
| 128 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 125 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 129 | 126 | $value = $row[strtolower($field)]; |
| 130 | 127 | } |
| 131 | 128 | |
| 132 | - if($value!==false) |
|
| 133 | - $Entity->{$method_set}($value); |
|
| 129 | + if($value!==false) { |
|
| 130 | + $Entity->{$method_set}($value); |
|
| 131 | + } |
|
| 134 | 132 | |
| 135 | 133 | } |
| 136 | 134 | |
@@ -161,18 +159,17 @@ discard block |
||
| 161 | 159 | //-------------------------------------------------------------------- |
| 162 | 160 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
| 163 | 161 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
| 164 | - } |
|
| 165 | - elseif(isset($cfg['relation'])){ |
|
| 162 | + } elseif(isset($cfg['relation'])){ |
|
| 166 | 163 | |
| 167 | - if(isset($cfg['on'])) |
|
| 168 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 169 | - else |
|
| 170 | - $fkey = 'id'; |
|
| 164 | + if(isset($cfg['on'])) { |
|
| 165 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 166 | + } else { |
|
| 167 | + $fkey = 'id'; |
|
| 168 | + } |
|
| 171 | 169 | |
| 172 | 170 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
| 173 | 171 | |
| 174 | - } |
|
| 175 | - else{ |
|
| 172 | + } else{ |
|
| 176 | 173 | $value = $Entity->{$method_get}(); |
| 177 | 174 | } |
| 178 | 175 | |
@@ -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 | |