>data closure.Often there is no need to get value on index, so default value is null. $primaryKeys = Helper::getPrimaryKeys($this->primaryKeyIdentity, $this->primaryKeyFromMethod); $data = $this->data; if( $data instanceof Closure){ $params = []; if( !empty($primaryKeys) ){ foreach ($primaryKeys as $primaryKey) { array_push($params, $primaryKey); } } array_push($params, Yii::$app->getRequest()->getQueryParams()); array_push($params, $this); //execute closure then assign to view, the closure params like function($_GET, primaryKeyValue1, primaryKeyValue1 ..., IndexAction) $data = call_user_func_array( $this->data, $params ); if( !is_array($data) ){ throw new Exception("data closure must return array"); } }else if (!is_array($data) ){ throw new Exception(__CLASS__ . "::data must be array or closure"); } //default view template is action id $this->viewFile === null && $this->viewFile = $this->id; return $this->controller->render($this->viewFile, $data); } }