@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * таблица для сущности |
| 20 | 20 | * @var type |
| 21 | 21 | */ |
| 22 | - protected $entityTable; |
|
| 22 | + protected $entityTable; |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * первичный ключ |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | abstract protected function setMappingFields(); |
| 90 | 90 | |
| 91 | - public function getAdapter() { |
|
| 92 | - return $this->adapter; |
|
| 93 | - } |
|
| 91 | + public function getAdapter() { |
|
| 92 | + return $this->adapter; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | public function setAdapter(QueryBuilderInterface $adapter){ |
| 96 | 96 | $this->adapter = $adapter; |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - public function findById($id) |
|
| 113 | - { |
|
| 112 | + public function findById($id) |
|
| 113 | + { |
|
| 114 | 114 | $Criteria = (new Specification())->setWhere($this->key , $id); |
| 115 | 115 | |
| 116 | - return $this->findBySpecification($Criteria); |
|
| 117 | - } |
|
| 116 | + return $this->findBySpecification($Criteria); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Cохранение сущности |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function buildEntity(EntityInterface $Entity, array $row){ |
| 201 | 201 | |
| 202 | - foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 202 | + foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 203 | 203 | |
| 204 | 204 | $value = false; |
| 205 | 205 | |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | if($value!==false) |
| 237 | 237 | $Entity->{$method_set}($value); |
| 238 | 238 | |
| 239 | - } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - return $Entity; |
|
| 241 | + return $Entity; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | $row = []; |
| 254 | 254 | |
| 255 | - foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 255 | + foreach ($this->mapping_fields as $alias => $cfg ) { |
|
| 256 | 256 | |
| 257 | 257 | $field = $cfg['field']; |
| 258 | 258 | |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | $row[$field] = $value; |
| 284 | 284 | |
| 285 | - } |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - return $row; |
|
| 287 | + return $row; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -356,10 +356,10 @@ discard block |
||
| 356 | 356 | //получение записей |
| 357 | 357 | $res = $this->getAdapter()->getResultQuery($this->getEntityTable(),$specification); |
| 358 | 358 | |
| 359 | - if (!$row = $res->row_array()) { |
|
| 360 | - return null; |
|
| 361 | - } |
|
| 362 | - return $this->createEntity($row); |
|
| 359 | + if (!$row = $res->row_array()) { |
|
| 360 | + return null; |
|
| 361 | + } |
|
| 362 | + return $this->createEntity($row); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | $res = $this->getAdapter()->getResultQuery($this->getEntityTable(),$specification); |
| 402 | 402 | |
| 403 | 403 | if (!$rows = $res->result_array()) { |
| 404 | - return null; |
|
| 405 | - } |
|
| 404 | + return null; |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | 407 | foreach($rows as $k => $row){ |
| 408 | 408 | $rows[$k] = $this->createEntity($row); |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
| 433 | - * Построение join-ов |
|
| 434 | - */ |
|
| 433 | + * Построение join-ов |
|
| 434 | + */ |
|
| 435 | 435 | protected function setRelations(ISpecificationCriteria $Specification){ |
| 436 | 436 | |
| 437 | 437 | $joins = []; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | //----------------- |
| 59 | 59 | $mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields'); |
| 60 | 60 | |
| 61 | - $this->assertEquals($mapping_fields, $correct); |
|
| 61 | + $this->assertEquals($mapping_fields, $correct); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | //----------------- |
| 78 | 78 | $mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields'); |
| 79 | 79 | |
| 80 | - $this->assertEquals($mapping_fields, $correct); |
|
| 80 | + $this->assertEquals($mapping_fields, $correct); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | //----------------- |
| 99 | 99 | $mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields'); |
| 100 | 100 | |
| 101 | - $this->assertEquals($mapping_fields, $correct); |
|
| 101 | + $this->assertEquals($mapping_fields, $correct); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | //----------------- |
| 122 | 122 | $mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields'); |
| 123 | 123 | |
| 124 | - $this->assertEquals($mapping_fields, $correct); |
|
| 124 | + $this->assertEquals($mapping_fields, $correct); |
|
| 125 | 125 | |
| 126 | 126 | $key_field = \TestHelper::getProtectedAttribute($this->object,'key'); |
| 127 | 127 | $this->assertEquals($key_field, 'tb_mayfield'); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | //----------------- |
| 148 | 148 | $mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields'); |
| 149 | 149 | |
| 150 | - $this->assertEquals($mapping_fields, $correct); |
|
| 150 | + $this->assertEquals($mapping_fields, $correct); |
|
| 151 | 151 | |
| 152 | 152 | $soft_delete_key = \TestHelper::getProtectedAttribute($this->object,'soft_delete_key'); |
| 153 | 153 | $this->assertEquals($soft_delete_key, 'tb_mayfield'); |
@@ -3,38 +3,38 @@ |
||
| 3 | 3 | |
| 4 | 4 | class TestHelper{ |
| 5 | 5 | |
| 6 | - /** |
|
| 7 | - * получение защищенного свойства |
|
| 8 | - * @param type $o |
|
| 9 | - * @param type $name |
|
| 10 | - * @return type |
|
| 11 | - */ |
|
| 12 | - static public function getProtectedAttribute($obj, $name) |
|
| 13 | - { |
|
| 14 | - $reflectionClass = new \ReflectionClass($obj); //создаем reflectionClass |
|
| 15 | - $r = $reflectionClass->getProperty($name); //получаем свойство |
|
| 16 | - $r->setAccessible(true); //делаем открытым |
|
| 17 | - return $r->getValue($obj); |
|
| 18 | - } |
|
| 6 | + /** |
|
| 7 | + * получение защищенного свойства |
|
| 8 | + * @param type $o |
|
| 9 | + * @param type $name |
|
| 10 | + * @return type |
|
| 11 | + */ |
|
| 12 | + static public function getProtectedAttribute($obj, $name) |
|
| 13 | + { |
|
| 14 | + $reflectionClass = new \ReflectionClass($obj); //создаем reflectionClass |
|
| 15 | + $r = $reflectionClass->getProperty($name); //получаем свойство |
|
| 16 | + $r->setAccessible(true); //делаем открытым |
|
| 17 | + return $r->getValue($obj); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Добавление значения в защищенное свойтсво |
|
| 22 | - * @param type $name |
|
| 23 | - * @param type $valued |
|
| 24 | - */ |
|
| 25 | - private function setValueprotectedProperty($name, $value) |
|
| 26 | - { |
|
| 27 | - $reflectionClass = new \ReflectionClass($this->object); //создаем reflectionClass |
|
| 28 | - $r = $reflectionClass->getProperty($name); //получаем свойство |
|
| 29 | - $r->setAccessible(true); //делаем открытым |
|
| 30 | - $r->setValue($this->object, $value); //изменяем значение |
|
| 31 | - } |
|
| 20 | + /** |
|
| 21 | + * Добавление значения в защищенное свойтсво |
|
| 22 | + * @param type $name |
|
| 23 | + * @param type $valued |
|
| 24 | + */ |
|
| 25 | + private function setValueprotectedProperty($name, $value) |
|
| 26 | + { |
|
| 27 | + $reflectionClass = new \ReflectionClass($this->object); //создаем reflectionClass |
|
| 28 | + $r = $reflectionClass->getProperty($name); //получаем свойство |
|
| 29 | + $r->setAccessible(true); //делаем открытым |
|
| 30 | + $r->setValue($this->object, $value); //изменяем значение |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | static public function callMethod($obj, $name, array $args) { |
| 34 | - $class = new \ReflectionClass($obj); |
|
| 35 | - $method = $class->getMethod($name); |
|
| 36 | - $method->setAccessible(true); |
|
| 37 | - return $method->invokeArgs($obj, $args); |
|
| 38 | - } |
|
| 34 | + $class = new \ReflectionClass($obj); |
|
| 35 | + $method = $class->getMethod($name); |
|
| 36 | + $method->setAccessible(true); |
|
| 37 | + return $method->invokeArgs($obj, $args); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |