本文整理汇总了PHP中yii\data\ActiveDataProvider::init方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveDataProvider::init方法的具体用法?PHP ActiveDataProvider::init怎么用?PHP ActiveDataProvider::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\data\ActiveDataProvider
的用法示例。
在下文中一共展示了ActiveDataProvider::init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!is_callable($this->mapFunction)) {
throw new \yii\base\InvalidConfigException('You must specify a function for execution `mapFunction`');
}
}
示例2: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!$this->query instanceof QueryInterface) {
throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\\db\\Query or its subclasses.');
}
$request = \Yii::$app->request;
if ($request->post('key')) {
if (!strcmp('history', $request->post('type'))) {
$this->query->andWhere(['<', 'id', $request->post('key')]);
} else {
$this->query->andWhere(['>', 'id', $request->post('key')]);
}
}
}
示例3: init
/**
* @inheritdoc
*/
public function init()
{
if (!$this->category_id) {
throw new InvalidConfigException('The "category_id" property must be set.');
}
$query = Catalog::find()->select(['id', 'title', 'cost', 'category_id'])->where(['category_id' => $this->category_id]);
$this->categoryAttributes = CatalogAttributes::find()->where(['category_id' => $this->category_id])->orderBy('id')->all();
$query = (new \yii\db\Query())->select(['t.id', 't.title', 't.cost', 't.category_id'])->from(['t' => $query]);
foreach ($this->categoryAttributes as $x) {
$query->addSelect([$x->code . '.value as ' . $x->code]);
$query->leftJoin([$x->code => (new \yii\db\Query())->from(CatalogValues::tableName())], $x->code . '.catalog_id = t.id and ' . $x->code . '.attribute_id = ' . $x->id);
$query->addSelect(['categoryAttribute[' . $x->id . ']' => 'categoryAttribute[' . $x->id . '].value']);
$query->leftJoin(['categoryAttribute[' . $x->id . ']' => (new \yii\db\Query())->from(CatalogValues::tableName())], ['categoryAttribute[' . $x->id . '].catalog_id' => 't.id', 'categoryAttribute[' . $x->id . '].attribute_id' => $x->id]);
}
$query = (new \yii\db\Query())->select(['t.*'])->from(['t' => $query]);
$this->query = $query;
parent::init();
}
示例4: init
public function init()
{
parent::init();
if (!isset($this->pagination['pageSize'])) {
$pageSize = (int) Yii::$app->request->get('pageSize') ?: self::DEFAULT_PAGE_SIZE;
$this->pagination['pageSize'] = $pageSize;
}
if (empty($this->filters)) {
$filters = Yii::$app->request->get('filter');
if ($filters) {
$filtersCollection = $filters ? new KendoFiltersCollection($filters) : null;
$this->filters = $filtersCollection;
}
}
if (!$this->sorting) {
$sort = Yii::$app->request->get('sort');
if ($sort) {
$this->sorting = $sort;
}
}
}
示例5: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->pageFromPk = Yii::$app->request->get('page-from-pk');
}
示例6: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
}