@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | public function run($id, $position) |
50 | 50 | { |
51 | 51 | if (empty($this->modelClass) || !class_exists($this->modelClass)) { |
52 | - throw new InvalidParamException('Define model class name for action ' . $this->controller->id . '::' . $this->id); |
|
52 | + throw new InvalidParamException('Define model class name for action '.$this->controller->id.'::'.$this->id); |
|
53 | 53 | } |
54 | 54 | /** @var ActiveRecord $class */ |
55 | 55 | $class = $this->modelClass; |
56 | 56 | /** @var SortableBehavior $model */ |
57 | 57 | $model = $class::findOne($id); |
58 | 58 | if (!$model) { |
59 | - throw new HttpException(404, 'Model `' . $this->modelClass . '` to change sort not found'); |
|
59 | + throw new HttpException(404, 'Model `'.$this->modelClass.'` to change sort not found'); |
|
60 | 60 | } |
61 | 61 | switch ($position) { |
62 | 62 | case 'top': |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | default: |
71 | 71 | if (strpos('ud-', $position[0]) !== false) { |
72 | 72 | // relative position |
73 | - $position = ($position[0] == 'd' ? '-' : '') . substr($position, 1); |
|
73 | + $position = ($position[0] == 'd' ? '-' : '').substr($position, 1); |
|
74 | 74 | if (is_numeric($position)) { |
75 | 75 | $model->sortChange($position); |
76 | 76 | } |
@@ -81,7 +81,6 @@ discard block |
||
81 | 81 | break; |
82 | 82 | } |
83 | 83 | return Yii::$app->response->format == Response::FORMAT_JSON ? |
84 | - ['status' => 200] : |
|
85 | - $this->controller->redirect($this->redirectUrl); |
|
84 | + ['status' => 200] : $this->controller->redirect($this->redirectUrl); |
|
86 | 85 | } |
87 | 86 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $currentCondition = []; |
78 | 78 | /** @var ActiveRecord $owner */ |
79 | 79 | $owner = $this->owner; |
80 | - foreach ((array)$this->conditionAttributes as $attribute) { |
|
80 | + foreach ((array) $this->conditionAttributes as $attribute) { |
|
81 | 81 | if (!$owner->hasAttribute($attribute)) { |
82 | 82 | continue; |
83 | 83 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | $owner = $this->owner; |
145 | 145 | $condition = $this->getCondition(); |
146 | - $newSort = $owner->{$this->sortAttribute} + $value; |
|
146 | + $newSort = $owner->{$this->sortAttribute} +$value; |
|
147 | 147 | if ($value > 0) { |
148 | 148 | // move up |
149 | 149 | $max = $this->getMaxSort(); |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | [$this->sortAttribute => new Expression('(@sortingCount:=(@sortingCount+1))')], |
194 | 194 | $this->getCondition(), |
195 | 195 | $params |
196 | - ) . ' ' . $builder->buildOrderBy($orderFields); |
|
197 | - $db->createCommand('set @sortingCount=-1;' . $query, $params)->execute(); |
|
196 | + ).' '.$builder->buildOrderBy($orderFields); |
|
197 | + $db->createCommand('set @sortingCount=-1;'.$query, $params)->execute(); |
|
198 | 198 | // update in current record |
199 | 199 | if (!$owner->getIsNewRecord()) { |
200 | 200 | $owner->{$this->sortAttribute} = $owner->findOne($owner->getPrimaryKey())->{$this->sortAttribute}; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | { |
221 | 221 | if ($this->_condition === null) { |
222 | 222 | $this->_condition = ['and']; |
223 | - foreach ((array)$this->conditionAttributes as $attribute) { |
|
223 | + foreach ((array) $this->conditionAttributes as $attribute) { |
|
224 | 224 | if ($this->owner->hasAttribute($attribute)) { |
225 | 225 | $this->_condition[] = [$attribute => $this->owner->$attribute]; |
226 | 226 | } |