for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Anton Tuyakhov <[email protected]>
*/
namespace tuyakhov\jsonapi\actions;
use yii\data\ActiveDataProvider;
class IndexAction extends Action
{
* @var callable a PHP callable that will be called to prepare a data provider that
* should return a collection of the models. If not set, [[prepareDataProvider()]] will be used instead.
* The signature of the callable should be:
*
* ```php
* function ($action) {
* // $action is the action object currently running
* }
* ```
* The callable should return an instance of [[ActiveDataProvider]].
public $prepareDataProvider;
* @return ActiveDataProvider
public function run()
if ($this->checkAccess) {
call_user_func($this->checkAccess, $this->id);
}
return $this->prepareDataProvider();
* Prepares the data provider that should return the requested collection of the models.
protected function prepareDataProvider()
if ($this->prepareDataProvider !== null) {
return call_user_func($this->prepareDataProvider, $this);
/* @var $modelClass \yii\db\BaseActiveRecord */
$modelClass = $this->modelClass;
return new ActiveDataProvider([
'query' => $modelClass::find(),
]);