Skip to content

Commit 062368d

Browse files
committed
PSR-2 fix
1 parent eadb1a0 commit 062368d

6 files changed

+271
-271
lines changed

LICENSE

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
The MIT License (MIT)
2-
3-
Copyright (c) 2014 HimikLab
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 HimikLab
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.

README.md

+59-59
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
Sortable GridView Widget for Yii2
2-
========================
3-
4-
Sortable modification of Yii2 GridView widget.
5-
6-
Installation
7-
------------
8-
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
9-
10-
Either run
11-
12-
```
13-
php composer.phar require "himiklab/yii2-sortable-grid-view-widget" "*"
14-
```
15-
or add
16-
17-
```json
18-
"himiklab/yii2-sortable-grid-view-widget" : "*"
19-
```
20-
21-
to the require section of your application's `composer.json` file.
22-
23-
Usage
24-
-----
25-
* Add in the AR model new uint attribute, such `sortOrder`.
26-
27-
* Add action in the controller:
28-
29-
```php
30-
use himiklab\sortablegrid\SortableGridAction;
31-
32-
public function actions()
33-
{
34-
return [
35-
'sort' => [
36-
'class' => SortableGridAction::className(),
37-
'modelName' => Model::className(),
38-
],
39-
];
40-
}
41-
```
42-
43-
* Add behavior in the AR model:
44-
45-
```php
46-
use himiklab\sortablegrid\SortableGridBehavior;
47-
48-
public function behaviors()
49-
{
50-
return [
51-
'sort' => [
52-
'class' => SortableGridBehavior::className(),
53-
'sortableAttribute' => 'sortOrder'
54-
],
55-
];
56-
}
57-
```
58-
59-
* Use SortableGridView as standard GridView with `sortableAction` option.
1+
Sortable GridView Widget for Yii2
2+
========================
3+
4+
Sortable modification of Yii2 GridView widget.
5+
6+
Installation
7+
------------
8+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
9+
10+
Either run
11+
12+
```
13+
php composer.phar require "himiklab/yii2-sortable-grid-view-widget" "*"
14+
```
15+
or add
16+
17+
```json
18+
"himiklab/yii2-sortable-grid-view-widget" : "*"
19+
```
20+
21+
to the require section of your application's `composer.json` file.
22+
23+
Usage
24+
-----
25+
* Add in the AR model new uint attribute, such `sortOrder`.
26+
27+
* Add action in the controller:
28+
29+
```php
30+
use himiklab\sortablegrid\SortableGridAction;
31+
32+
public function actions()
33+
{
34+
return [
35+
'sort' => [
36+
'class' => SortableGridAction::className(),
37+
'modelName' => Model::className(),
38+
],
39+
];
40+
}
41+
```
42+
43+
* Add behavior in the AR model:
44+
45+
```php
46+
use himiklab\sortablegrid\SortableGridBehavior;
47+
48+
public function behaviors()
49+
{
50+
return [
51+
'sort' => [
52+
'class' => SortableGridBehavior::className(),
53+
'sortableAttribute' => 'sortOrder'
54+
],
55+
];
56+
}
57+
```
58+
59+
* Use SortableGridView as standard GridView with `sortableAction` option.

SortableGridAction.php

+52-52
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
<?php
2-
/**
3-
* @link https://github.com/himiklab/yii2-sortable-grid-view-widget
4-
* @copyright Copyright (c) 2014 HimikLab
5-
* @license http://opensource.org/licenses/MIT
6-
*/
7-
8-
namespace himiklab\sortablegrid;
9-
10-
use yii\base\Action;
11-
use yii\base\InvalidConfigException;
12-
use yii\web\BadRequestHttpException;
13-
14-
/**
15-
* Action for sortable Yii2 GridView widget.
16-
*
17-
* For example:
18-
*
19-
* ```php
20-
* public function actions()
21-
* {
22-
* return [
23-
* 'sort' => [
24-
* 'class' => SortableGridAction::className(),
25-
* 'modelName' => Model::className(),
26-
* ],
27-
* ];
28-
* }
29-
* ```
30-
*
31-
* @author HimikLab
32-
* @package himiklab\sortablegrid
33-
*/
34-
class SortableGridAction extends Action
35-
{
36-
public $modelName;
37-
38-
public function run()
39-
{
40-
if (!isset($_POST['items']) || !is_array($_POST['items'])) {
41-
throw new BadRequestHttpException();
42-
}
43-
44-
/** @var \yii\db\ActiveRecord $model */
45-
$model = new $this->modelName;
46-
if (!$model->hasMethod('gridSort', true)) {
47-
throw new InvalidConfigException("Not found right SortableGridBehavior in {$this->modelName}.");
48-
}
49-
50-
$model->gridSort($_POST['items']);
51-
}
52-
}
1+
<?php
2+
/**
3+
* @link https://github.com/himiklab/yii2-sortable-grid-view-widget
4+
* @copyright Copyright (c) 2014 HimikLab
5+
* @license http://opensource.org/licenses/MIT MIT
6+
*/
7+
8+
namespace himiklab\sortablegrid;
9+
10+
use yii\base\Action;
11+
use yii\base\InvalidConfigException;
12+
use yii\web\BadRequestHttpException;
13+
14+
/**
15+
* Action for sortable Yii2 GridView widget.
16+
*
17+
* For example:
18+
*
19+
* ```php
20+
* public function actions()
21+
* {
22+
* return [
23+
* 'sort' => [
24+
* 'class' => SortableGridAction::className(),
25+
* 'modelName' => Model::className(),
26+
* ],
27+
* ];
28+
* }
29+
* ```
30+
*
31+
* @author HimikLab
32+
* @package himiklab\sortablegrid
33+
*/
34+
class SortableGridAction extends Action
35+
{
36+
public $modelName;
37+
38+
public function run()
39+
{
40+
if (!isset($_POST['items']) || !is_array($_POST['items'])) {
41+
throw new BadRequestHttpException();
42+
}
43+
44+
/** @var \yii\db\ActiveRecord $model */
45+
$model = new $this->modelName;
46+
if (!$model->hasMethod('gridSort', true)) {
47+
throw new InvalidConfigException("Not found right SortableGridBehavior in {$this->modelName}.");
48+
}
49+
50+
$model->gridSort($_POST['items']);
51+
}
52+
}

SortableGridAsset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @link https://github.com/himiklab/yii2-sortable-grid-view-widget
44
* @copyright Copyright (c) 2014 HimikLab
5-
* @license http://opensource.org/licenses/MIT
5+
* @license http://opensource.org/licenses/MIT MIT
66
*/
77

88
namespace himiklab\sortablegrid;

0 commit comments

Comments
 (0)