Skip to content

Commit 26e9d9f

Browse files
author
igor
committed
add 'searchClass' property to CronLogAction
1 parent 22fa792 commit 26e9d9f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ Usage
6060
{
6161
return [
6262
'cron' => 'yii2mod\cron\actions\CronLogAction',
63+
// Also you can override some action properties in following way:
64+
'searchClass' => [
65+
'class' => 'yii2mod\cron\models\search\CronScheduleSearch',
66+
'pageSize' => 10
67+
],
68+
'view' => 'custom name of the view, which should be rendered.'
6369
];
6470
}
6571
```

actions/CronLogAction.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Yii;
66
use yii\base\Action;
7-
use yii2mod\cron\models\search\CronScheduleSearch;
87

98
/**
109
* Class CronLogAction
@@ -17,12 +16,17 @@ class CronLogAction extends Action
1716
*/
1817
public $view = '@vendor/yii2mod/yii2-cron-log/views/index';
1918

19+
/**
20+
* @var string search class name for searching
21+
*/
22+
public $searchClass = 'yii2mod\cron\models\search\CronScheduleSearch';
23+
2024
/**
2125
* Lists of all cron logs.
2226
*/
2327
public function run()
2428
{
25-
$searchModel = new CronScheduleSearch();
29+
$searchModel = Yii::createObject($this->searchClass);
2630
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
2731

2832
return $this->controller->render($this->view, [

models/search/CronScheduleSearch.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
*/
1212
class CronScheduleSearch extends CronScheduleModel
1313
{
14+
/**
15+
* @var int the default page size.
16+
*/
17+
public $pageSize = 25;
18+
1419
/**
1520
* @inheritdoc
1621
*/
@@ -36,7 +41,7 @@ public function search($params)
3641
'query' => $query,
3742
'sort' => ['defaultOrder' => ['id' => SORT_DESC]],
3843
'pagination' => [
39-
'pageSize' => 20
44+
'pageSize' => $this->pageSize
4045
]
4146
]);
4247

0 commit comments

Comments
 (0)