|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
-
-
- namespace yii\rest;
-
- use Yii;
- use yii\data\ActiveDataProvider;
-
-
- class IndexAction extends Action
- {
-
-
- public $prepareDataProvider;
-
-
-
-
- public function run()
- {
- if ($this->checkAccess) {
- call_user_func($this->checkAccess, $this->id);
- }
-
- return $this->prepareDataProvider();
- }
-
-
-
- protected function prepareDataProvider()
- {
- if ($this->prepareDataProvider !== null) {
- return call_user_func($this->prepareDataProvider, $this);
- }
-
-
- $modelClass = $this->modelClass;
-
- return new ActiveDataProvider([
- 'query' => $modelClass::find(),
- ]);
- }
- }
|