本文整理汇总了PHP中yii\data\ActiveDataProvider::className方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveDataProvider::className方法的具体用法?PHP ActiveDataProvider::className怎么用?PHP ActiveDataProvider::className使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\data\ActiveDataProvider
的用法示例。
在下文中一共展示了ActiveDataProvider::className方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* @param array $params
* @return ArrayDataProvider
*/
public function search(array $params = [])
{
$query = (new Query())->select(['name', 'data', 'created_at', 'updated_at'])->from($this->authManager->ruleTable)->orderBy(['name' => SORT_ASC]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
}
$query->andFilterWhere(['name' => $this->name]);
return \Yii::createObject(['class' => ActiveDataProvider::className(), 'query' => $query, 'db' => $this->authManager->db, 'sort' => ['attributes' => ['name', 'created_at', 'updated_at']]]);
}
示例2: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Country::find();
$dataProvider = Yii::createObject(['class' => ActiveDataProvider::className(), 'query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['population' => $this->population]);
$query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
示例3: publicSearch
/**
* Возвращает провайдер данных
* @return ActiveDataProvider
*/
public function publicSearch()
{
$query = $this->find();
$query->modelClass = get_parent_class($this);
if ($this->validate()) {
$query->bySections($this->sectionsIds);
foreach ($this->metaFields->fields as $field) {
$field->applySearch($query);
}
} else {
$query->where(new Expression("1!=1"));
}
$dataProvider = Yii::createObject(['class' => ActiveDataProvider::className(), "query" => $query]);
return $dataProvider;
}
示例4: run
/**
* @inheritdoc
*/
public function run()
{
$this->registerAssets();
$this->processDelete();
/** @var Comments\models\Comment $CommentModel */
$CommentModel = \Yii::createObject(Comments\Module::instance()->model('comment'));
$CommentsQuery = $CommentModel::find()->byEntity($this->entity);
if (false === $this->showDeleted) {
$CommentsQuery->withoutDeleted();
}
$CommentsDataProvider = \Yii::createObject(['class' => \yii\data\ActiveDataProvider::className(), 'query' => $CommentsQuery->with(['author', 'lastUpdateAuthor']), 'pagination' => $this->pagination, 'sort' => $this->sort]);
$params = $this->viewParams;
$params['CommentsDataProvider'] = $CommentsDataProvider;
$content = $this->render($this->viewFile, $params);
return Html::tag('div', $content, $this->options);
}
示例5: search
/**
* Returns data provider with filled models. Filter applied if needed.
*
* @param array $params an array of parameter values indexed by parameter names
* @return ActiveDataProvider
*/
public function search($params)
{
$this->load($params) && $this->validate();
/** @var \yii\db\BaseActiveRecord $Model */
$Model = Instance::ensure(['class' => Changelog::className()]);
/** @var ChangelogQuery $ChangelogQuery */
$ChangelogQuery = $Model::find();
if (!empty($this->action)) {
$ChangelogQuery->byAction($this->action);
}
if (!empty($this->entity_type)) {
$ChangelogQuery->byEntityType($this->entity_type);
}
if (!empty($this->entity_id)) {
$ChangelogQuery->byEntityId($this->entity_id);
}
/** @var ActiveDataProvider $DataProvider */
$DataProvider = \Yii::createObject(['class' => ActiveDataProvider::className(), 'query' => $ChangelogQuery, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
return $DataProvider;
}
示例6: publicSearch
/**
* Возвращает провайдер данных для отображения списка фотогалерей в публичной части
* @return \yii\data\ActiveDataProvider
* @throws \yii\base\InvalidConfigException
*/
public function publicSearch()
{
$query = $this->find()->published();
$dataProvider = Yii::createObject(['class' => ActiveDataProvider::className(), "query" => $query]);
return $dataProvider;
}
示例7: getDataProvider
/**
* Возвращает объект провайдера данных
* @return object|ActiveDataProvider
* @throws \yii\base\InvalidConfigException
*/
public function getDataProvider()
{
if (is_null($this->_dataProvider)) {
$query = Review::find()->published()->byItem($this->itemId, $this->modelClass);
if (is_callable($this->queryModifier)) {
$func = $this->queryModifier;
$func($query);
}
$config = ArrayHelper::merge($this->dataProviderConfig, ['class' => ActiveDataProvider::className(), 'query' => $query]);
$this->_dataProvider = Yii::createObject($config);
$this->_dataProvider->pagination->pageSize = $this->pageSize;
$this->_dataProvider->sort->defaultOrder = $this->orderBy;
}
return $this->_dataProvider;
}
示例8: search
/**
* Возвращает провайдер данных для поиска
* @param array $params массив значений атрибутов модели
* @param array $dataProviderConfig параметры провайдера данных
* @param \common\db\ActiveQuery $query запрос
* @return \yii\data\ActiveDataProvider
*/
public function search($params, $dataProviderConfig = [], $query = null)
{
$fields = $this->getMetaFields()->getFields();
$query = $query ? $query : static::find();
$config = array_merge(['class' => ActiveDataProvider::className(), "query" => $query], $dataProviderConfig);
$dataProvider = Yii::createObject($config);
$dataProvider->getSort()->defaultOrder = $this->_defaultSearchOrder;
$this->load($params);
$this->validate();
foreach ($fields as $field) {
if ($field->search) {
$field->applySearch($query);
}
}
return $dataProvider;
}
示例9: searchBySection
/**
* Поиск новостей по категориям. Если идентификаторы категорий не заданы выбираются все элементы.
* @param null|array $ids массив идентификаторов категорий
* @return \yii\data\ActiveDataProvider провайдер данных
* @throws \yii\base\InvalidConfigException
*/
public function searchBySection($ids = null)
{
$query = $this->find()->bySections($ids);
$dataProvider = Yii::createObject(['class' => ActiveDataProvider::className(), "query" => $query]);
return $dataProvider;
}
示例10: dataProviderClassName
/**
* Имя класса дата-провайдера
* @return string
*/
public function dataProviderClassName()
{
return ActiveDataProvider::className();
}
示例11: getDataProvider
/**
* Returns data provider for contacts
* @return object|ActiveDataProvider
* @throws \yii\base\InvalidConfigException
*/
public function getDataProvider()
{
if (is_null($this->_dataProvider)) {
$query = Contact::find()->byUser($this->userId)->with(['lastMessage', 'lastMessageAuthor']);
if (is_callable($this->queryModifier)) {
$func = $this->queryModifier;
$func($query);
}
$this->_dataProvider = Yii::createObject(ArrayHelper::merge(['class' => ActiveDataProvider::className(), 'query' => $query], $this->dataProviderOptions));
$this->_dataProvider->sort->defaultOrder = $this->defaultOrder;
$this->_dataProvider->pagination->pageSize = $this->pageSize;
}
return $this->_dataProvider;
}
示例12: init
/**
* @inheritdoc
*/
public function init()
{
$skin = $this->skinAsset;
if ($skin) {
$skin::register($this->view);
}
CommentsAsset::register($this->view);
$parent = Model::findOne(TActiveRecord::ROOT_ID);
$query = $parent->children()->published()->andWhere(["model" => $this->modelClass, "item_id" => $this->itemId]);
if (is_callable($this->queryModifier)) {
$func = $this->queryModifier;
$func($query);
}
$config = array_merge(['class' => ActiveDataProvider::className(), "query" => $query], $this->dataProviderConfig);
$this->dataProvider = Yii::createObject($config);
$this->dataProvider->getPagination()->pageSize = $this->pageSize;
$id = $this->getId();
$this->view->registerJs("\$('#{$id}').commentsWidget()");
}