IndexAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 3
b 0
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 2
1
<?php
2
3
4
namespace carono\yii2crud\actions;
5
6
7
use carono\yii2crud\CrudController;
8
use yii\db\ActiveRecord;
9
10
/**
11
 * Class IndexAction
12
 *
13
 * @package carono\yii2crud\actions
14
 * @property CrudController $controller
15
 */
16
class IndexAction extends Action
17
{
18
    public $view = 'index';
19
20
    public function run()
21
    {
22
        /**
23
         * @var ActiveRecord $searchModel
24
         */
25
        $classModel = $this->controller->modelClass;
26
        $searchModel = $this->controller->modelSearchClass ? new $this->controller->modelSearchClass : null;
27
        $query = $this->controller->getModelQuery($classModel);
28
        $dataProvider = $this->controller->queryToDataProvider($query);
29
30
        $this->controller->indexCondition($query);
31
        $this->controller->applySearch($query, $dataProvider, $searchModel);
32
33
        $params = $this->controller->indexParams(['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
34
        return $this->controller->render($this->view, $params);
35
    }
36
}