| @@ -10,43 +10,43 @@ | ||
| 10 | 10 | */ | 
| 11 | 11 | interface ISpecificationCriteria | 
| 12 | 12 |  { | 
| 13 | - public function getCriteria(); | |
| 13 | + public function getCriteria(); | |
| 14 | 14 | |
| 15 | 15 | public function getWhere(); | 
| 16 | 16 | |
| 17 | - public function getLimit(); | |
| 17 | + public function getLimit(); | |
| 18 | 18 | |
| 19 | - public function getOfset(); | |
| 19 | + public function getOfset(); | |
| 20 | 20 | |
| 21 | - public function getJoins(); | |
| 21 | + public function getJoins(); | |
| 22 | 22 | |
| 23 | - public function getOrder(); | |
| 23 | + public function getOrder(); | |
| 24 | 24 | |
| 25 | - public function getManualJoins(); | |
| 25 | + public function getManualJoins(); | |
| 26 | 26 | |
| 27 | - public function getGroup(); | |
| 27 | + public function getGroup(); | |
| 28 | 28 | |
| 29 | - public function getManualWheres(); | |
| 29 | + public function getManualWheres(); | |
| 30 | 30 | |
| 31 | - public function getWhereType(); | |
| 31 | + public function getWhereType(); | |
| 32 | 32 | |
| 33 | - public function setWhere($field,$value = false); | |
| 33 | + public function setWhere($field,$value = false); | |
| 34 | 34 | |
| 35 | - public function setLimit($limit); | |
| 35 | + public function setLimit($limit); | |
| 36 | 36 | |
| 37 | - public function setOfset($ofset); | |
| 37 | + public function setOfset($ofset); | |
| 38 | 38 | |
| 39 | - public function setJoins($joins); | |
| 39 | + public function setJoins($joins); | |
| 40 | 40 | |
| 41 | - public function setOrder($order); | |
| 41 | + public function setOrder($order); | |
| 42 | 42 | |
| 43 | - public function setManualJoins($manualJoins); | |
| 43 | + public function setManualJoins($manualJoins); | |
| 44 | 44 | |
| 45 | - public function setGroup($group); | |
| 45 | + public function setGroup($group); | |
| 46 | 46 | |
| 47 | - public function setManualWheres($manualWheres); | |
| 47 | + public function setManualWheres($manualWheres); | |
| 48 | 48 | |
| 49 | - public function setWhereType($whereType); | |
| 49 | + public function setWhereType($whereType); | |
| 50 | 50 | |
| 51 | 51 | } | 
| 52 | 52 | |
| @@ -10,29 +10,29 @@ | ||
| 10 | 10 | abstract class AbstractEntity implements EntityInterface | 
| 11 | 11 |  { | 
| 12 | 12 | |
| 13 | - protected $id; | |
| 13 | + protected $id; | |
| 14 | 14 | |
| 15 | 15 | protected $deleted; | 
| 16 | 16 | |
| 17 | 17 | public function getId() | 
| 18 | -    { | |
| 19 | - return $this->id; | |
| 20 | - } | |
| 18 | +	{ | |
| 19 | + return $this->id; | |
| 20 | + } | |
| 21 | 21 | |
| 22 | - public function setId($id) | |
| 23 | -    { | |
| 24 | -        if ($this->id !== null) { | |
| 25 | - throw new BadMethodCallException( | |
| 26 | - "Идентификатор у сущности уже установлен"); | |
| 27 | - } | |
| 22 | + public function setId($id) | |
| 23 | +	{ | |
| 24 | +		if ($this->id !== null) { | |
| 25 | + throw new BadMethodCallException( | |
| 26 | + "Идентификатор у сущности уже установлен"); | |
| 27 | + } | |
| 28 | 28 | |
| 29 | -        if ($id < 1) { | |
| 30 | -            throw new InvalidArgumentException("Неверный индентификатор"); | |
| 31 | - } | |
| 29 | +		if ($id < 1) { | |
| 30 | +			throw new InvalidArgumentException("Неверный индентификатор"); | |
| 31 | + } | |
| 32 | 32 | |
| 33 | - $this->id = $id; | |
| 34 | - return $this; | |
| 35 | - } | |
| 33 | + $this->id = $id; | |
| 34 | + return $this; | |
| 35 | + } | |
| 36 | 36 | |
| 37 | 37 |  	public function setDeleted($deleted){ | 
| 38 | 38 | $this->deleted = $deleted; | 
| @@ -10,134 +10,134 @@ | ||
| 10 | 10 | class Specification implements ISpecificationCriteria | 
| 11 | 11 |  { | 
| 12 | 12 | |
| 13 | - protected $where = []; | |
| 13 | + protected $where = []; | |
| 14 | 14 | |
| 15 | - protected $limit = 0; | |
| 15 | + protected $limit = 0; | |
| 16 | 16 | |
| 17 | - protected $ofset = 0; | |
| 17 | + protected $ofset = 0; | |
| 18 | 18 | |
| 19 | - protected $joins = []; | |
| 19 | + protected $joins = []; | |
| 20 | 20 | |
| 21 | - protected $order = []; | |
| 21 | + protected $order = []; | |
| 22 | 22 | |
| 23 | - protected $manualJoins = []; | |
| 23 | + protected $manualJoins = []; | |
| 24 | 24 | |
| 25 | - protected $group = null; | |
| 25 | + protected $group = null; | |
| 26 | 26 | |
| 27 | - protected $manualWheres = []; | |
| 27 | + protected $manualWheres = []; | |
| 28 | 28 | |
| 29 | - protected $whereType = 'AND'; | |
| 29 | + protected $whereType = 'AND'; | |
| 30 | 30 | |
| 31 | - function getWhere() | |
| 32 | -    { | |
| 33 | - return $this->where; | |
| 34 | - } | |
| 35 | - | |
| 36 | - function getLimit() | |
| 37 | -    { | |
| 38 | - return $this->limit; | |
| 39 | - } | |
| 40 | - | |
| 41 | - function getOfset() | |
| 42 | -    { | |
| 43 | - return $this->ofset; | |
| 44 | - } | |
| 45 | - | |
| 46 | - function getJoins() | |
| 47 | -    { | |
| 48 | - return $this->joins; | |
| 49 | - } | |
| 50 | - | |
| 51 | - function getOrder() | |
| 52 | -    { | |
| 53 | - return $this->order; | |
| 54 | - } | |
| 55 | - | |
| 56 | - function getManualJoins() | |
| 57 | -    { | |
| 58 | - return $this->manualJoins; | |
| 59 | - } | |
| 60 | - | |
| 61 | - function getGroup() | |
| 62 | -    { | |
| 63 | - return $this->group; | |
| 64 | - } | |
| 65 | - | |
| 66 | - function getManualWheres() | |
| 67 | -    { | |
| 68 | - return $this->manualWheres; | |
| 69 | - } | |
| 70 | - | |
| 71 | - function getWhereType() | |
| 72 | -    { | |
| 73 | - return $this->whereType; | |
| 74 | - } | |
| 75 | - | |
| 76 | - function setWhere($field,$value = false) | |
| 77 | -    { | |
| 78 | -        if($value!==false){ | |
| 79 | - $this->where[$field] = $value; | |
| 80 | - } | |
| 81 | -        else{ | |
| 82 | - $this->where = $where; | |
| 83 | - } | |
| 31 | + function getWhere() | |
| 32 | +	{ | |
| 33 | + return $this->where; | |
| 34 | + } | |
| 35 | + | |
| 36 | + function getLimit() | |
| 37 | +	{ | |
| 38 | + return $this->limit; | |
| 39 | + } | |
| 40 | + | |
| 41 | + function getOfset() | |
| 42 | +	{ | |
| 43 | + return $this->ofset; | |
| 44 | + } | |
| 45 | + | |
| 46 | + function getJoins() | |
| 47 | +	{ | |
| 48 | + return $this->joins; | |
| 49 | + } | |
| 50 | + | |
| 51 | + function getOrder() | |
| 52 | +	{ | |
| 53 | + return $this->order; | |
| 54 | + } | |
| 55 | + | |
| 56 | + function getManualJoins() | |
| 57 | +	{ | |
| 58 | + return $this->manualJoins; | |
| 59 | + } | |
| 60 | + | |
| 61 | + function getGroup() | |
| 62 | +	{ | |
| 63 | + return $this->group; | |
| 64 | + } | |
| 65 | + | |
| 66 | + function getManualWheres() | |
| 67 | +	{ | |
| 68 | + return $this->manualWheres; | |
| 69 | + } | |
| 70 | + | |
| 71 | + function getWhereType() | |
| 72 | +	{ | |
| 73 | + return $this->whereType; | |
| 74 | + } | |
| 75 | + | |
| 76 | + function setWhere($field,$value = false) | |
| 77 | +	{ | |
| 78 | +		if($value!==false){ | |
| 79 | + $this->where[$field] = $value; | |
| 80 | + } | |
| 81 | +		else{ | |
| 82 | + $this->where = $where; | |
| 83 | + } | |
| 84 | 84 | |
| 85 | - return $this; | |
| 86 | - } | |
| 87 | - | |
| 88 | - function setLimit($limit) | |
| 89 | -    { | |
| 90 | - $this->limit = $limit; | |
| 91 | - return $this; | |
| 92 | - } | |
| 93 | - | |
| 94 | - function setOfset($ofset) | |
| 95 | -    { | |
| 96 | - $this->ofset = $ofset; | |
| 97 | - return $this; | |
| 98 | - } | |
| 99 | - | |
| 100 | - function setJoins($joins) | |
| 101 | -    { | |
| 102 | - $this->joins = $joins; | |
| 103 | - return $this; | |
| 104 | - } | |
| 105 | - | |
| 106 | - function setOrder($order) | |
| 107 | -    { | |
| 108 | - $this->order = $order; | |
| 109 | - return $this; | |
| 110 | - } | |
| 111 | - | |
| 112 | - function setManualJoins($manualJoins) | |
| 113 | -    { | |
| 114 | - $this->manualJoins = $manualJoins; | |
| 115 | - return $this; | |
| 116 | - } | |
| 117 | - | |
| 118 | - function setGroup($group) | |
| 119 | -    { | |
| 120 | - $this->group = $group; | |
| 121 | - return $this; | |
| 122 | - } | |
| 123 | - | |
| 124 | - function setManualWheres($manualWheres) | |
| 125 | -    { | |
| 126 | - $this->manualWheres = $manualWheres; | |
| 127 | - return $this; | |
| 128 | - } | |
| 129 | - | |
| 130 | - function setWhereType($whereType) | |
| 131 | -    { | |
| 132 | - $this->whereType = $whereType; | |
| 133 | - return $this; | |
| 134 | - } | |
| 135 | - | |
| 136 | - /** | |
| 137 | - * Создание критериев | |
| 138 | - */ | |
| 139 | - public function getCriteria() | |
| 140 | -    { | |
| 85 | + return $this; | |
| 86 | + } | |
| 87 | + | |
| 88 | + function setLimit($limit) | |
| 89 | +	{ | |
| 90 | + $this->limit = $limit; | |
| 91 | + return $this; | |
| 92 | + } | |
| 93 | + | |
| 94 | + function setOfset($ofset) | |
| 95 | +	{ | |
| 96 | + $this->ofset = $ofset; | |
| 97 | + return $this; | |
| 98 | + } | |
| 99 | + | |
| 100 | + function setJoins($joins) | |
| 101 | +	{ | |
| 102 | + $this->joins = $joins; | |
| 103 | + return $this; | |
| 104 | + } | |
| 105 | + | |
| 106 | + function setOrder($order) | |
| 107 | +	{ | |
| 108 | + $this->order = $order; | |
| 109 | + return $this; | |
| 110 | + } | |
| 111 | + | |
| 112 | + function setManualJoins($manualJoins) | |
| 113 | +	{ | |
| 114 | + $this->manualJoins = $manualJoins; | |
| 115 | + return $this; | |
| 116 | + } | |
| 117 | + | |
| 118 | + function setGroup($group) | |
| 119 | +	{ | |
| 120 | + $this->group = $group; | |
| 121 | + return $this; | |
| 122 | + } | |
| 123 | + | |
| 124 | + function setManualWheres($manualWheres) | |
| 125 | +	{ | |
| 126 | + $this->manualWheres = $manualWheres; | |
| 127 | + return $this; | |
| 128 | + } | |
| 129 | + | |
| 130 | + function setWhereType($whereType) | |
| 131 | +	{ | |
| 132 | + $this->whereType = $whereType; | |
| 133 | + return $this; | |
| 134 | + } | |
| 135 | + | |
| 136 | + /** | |
| 137 | + * Создание критериев | |
| 138 | + */ | |
| 139 | + public function getCriteria() | |
| 140 | +	{ | |
| 141 | 141 | |
| 142 | - } | |
| 142 | + } | |
| 143 | 143 | } | 
| @@ -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 | |
| @@ -10,15 +10,15 @@ | ||
| 10 | 10 | interface RepositoryInterface | 
| 11 | 11 |  { | 
| 12 | 12 | |
| 13 | - public function findById($id); | |
| 13 | + public function findById($id); | |
| 14 | 14 | |
| 15 | - public function findBySpecification(ISpecificationCriteria $specification); | |
| 15 | + public function findBySpecification(ISpecificationCriteria $specification); | |
| 16 | 16 | |
| 17 | - public function findAll(); | |
| 17 | + public function findAll(); | |
| 18 | 18 | |
| 19 | - public function findAllBySpecification(ISpecificationCriteria $specification); | |
| 19 | + public function findAllBySpecification(ISpecificationCriteria $specification); | |
| 20 | 20 | |
| 21 | - public function save(EntityInterface $Entity); | |
| 21 | + public function save(EntityInterface $Entity); | |
| 22 | 22 | |
| 23 | - public function delete(EntityInterface $Entity); | |
| 23 | + public function delete(EntityInterface $Entity); | |
| 24 | 24 | } | 
| @@ -8,12 +8,12 @@ | ||
| 8 | 8 | */ | 
| 9 | 9 | interface EntityInterface | 
| 10 | 10 |  { | 
| 11 | - //put your code here | |
| 12 | - public function getId(); | |
| 11 | + //put your code here | |
| 12 | + public function getId(); | |
| 13 | 13 | |
| 14 | - public function setId($id); | |
| 14 | + public function setId($id); | |
| 15 | 15 | |
| 16 | - public function getDeleted(); | |
| 16 | + public function getDeleted(); | |
| 17 | 17 | |
| 18 | - public function setDeleted($delete); | |
| 18 | + public function setDeleted($delete); | |
| 19 | 19 | } | 
| @@ -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 | } | 
| @@ -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 | } | 
| @@ -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охранение сущности | 
| @@ -210,7 +210,7 @@ discard block | ||
| 210 | 210 | */ | 
| 211 | 211 |  	protected function buildEntity(EntityInterface $Entity, array $row){ | 
| 212 | 212 | |
| 213 | -        foreach ($this->mapping_fields as $alias => $cfg ) { | |
| 213 | +		foreach ($this->mapping_fields as $alias => $cfg ) { | |
| 214 | 214 | |
| 215 | 215 | $value = false; | 
| 216 | 216 | |
| @@ -247,9 +247,9 @@ discard block | ||
| 247 | 247 | if($value!==false) | 
| 248 | 248 |  				$Entity->{$method_set}($value); | 
| 249 | 249 | |
| 250 | - } | |
| 250 | + } | |
| 251 | 251 | |
| 252 | - return $Entity; | |
| 252 | + return $Entity; | |
| 253 | 253 | } | 
| 254 | 254 | |
| 255 | 255 | |
| @@ -263,7 +263,7 @@ discard block | ||
| 263 | 263 | |
| 264 | 264 | $row = []; | 
| 265 | 265 | |
| 266 | -        foreach ($this->mapping_fields as $alias => $cfg ) { | |
| 266 | +		foreach ($this->mapping_fields as $alias => $cfg ) { | |
| 267 | 267 | |
| 268 | 268 | $field = $cfg['field']; | 
| 269 | 269 | |
| @@ -293,9 +293,9 @@ discard block | ||
| 293 | 293 | |
| 294 | 294 | $row[$field] = $value; | 
| 295 | 295 | |
| 296 | - } | |
| 296 | + } | |
| 297 | 297 | |
| 298 | - return $row; | |
| 298 | + return $row; | |
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | 301 | /** | 
| @@ -367,10 +367,10 @@ discard block | ||
| 367 | 367 | //получение записей | 
| 368 | 368 | $res = $this->getAdapter()->getResultQuery($this->getEntityTable(),$specification); | 
| 369 | 369 | |
| 370 | -        if (!$row = $res->row_array()) { | |
| 371 | - return null; | |
| 372 | - } | |
| 373 | - return $this->createEntity($row); | |
| 370 | +		if (!$row = $res->row_array()) { | |
| 371 | + return null; | |
| 372 | + } | |
| 373 | + return $this->createEntity($row); | |
| 374 | 374 | } | 
| 375 | 375 | |
| 376 | 376 | /** | 
| @@ -412,8 +412,8 @@ discard block | ||
| 412 | 412 | $res = $this->getAdapter()->getResultQuery($this->getEntityTable(),$specification); | 
| 413 | 413 | |
| 414 | 414 |  		if (!$rows = $res->result_array()) { | 
| 415 | - return null; | |
| 416 | - } | |
| 415 | + return null; | |
| 416 | + } | |
| 417 | 417 | |
| 418 | 418 |  		foreach($rows as $k =>  $row){ | 
| 419 | 419 | $rows[$k] = $this->createEntity($row); | 
| @@ -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 | /** |