| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 84.62% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | */ |
||
| 14 | class Index extends Action |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string model class to retreive the records on the collection. |
||
| 18 | */ |
||
| 19 | public string $searchClass; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string name of the form containing the filter data. |
||
| 23 | */ |
||
| 24 | public string $formName = ''; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @inheritdoc |
||
| 28 | 2 | */ |
|
| 29 | public function init() |
||
| 30 | 2 | { |
|
| 31 | $this->searchClass ?: throw new InvalidConfigException( |
||
| 32 | $this::class . '::$searchClass must be set.' |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | 2 | ||
| 36 | /** |
||
| 37 | * @return DataProviderInterface|ActiveRecordInterface |
||
| 38 | */ |
||
| 39 | public function run(): DataProvideInterface | ARContractSearch |
||
| 40 | 2 | { |
|
| 41 | $searchModel = $this->buildSearchModel(); |
||
| 42 | 2 | $dataProvider = $searchModel->search( |
|
| 43 | Yii::$app->request->getQueryParams(), |
||
| 44 | 2 | $this->formName |
|
| 45 | 2 | ); |
|
| 46 | 2 | $this->checkAccess($searchModel, Yii::$app->request->getQueryParams()); |
|
| 47 | 2 | ||
| 48 | return $dataProvider ?: $searchModel; |
||
| 49 | 2 | } |
|
| 50 | |||
| 51 | 2 | /** |
|
| 52 | * @return ARContractSearch the model used to create the data provider |
||
| 59 |