HumHub Documentation (unofficial)

DataProviderInterface

DataProviderInterface is the interface that must be implemented by data provider classes.

Data providers are components that sort and paginate data, and provide them to widgets such as [[\yii\grid\GridView]], [[\yii\widgets\ListView]].

For more details and usage information on DataProviderInterface, see the guide article on data providers.

Tags
author

Qiang Xue qiang.xue@gmail.com

since
2.0

Table of Contents

Methods

getCount()  : int
Returns the number of data models in the current page.
getKeys()  : array<string|int, mixed>
Returns the key values associated with the data models.
getModels()  : array<string|int, mixed>
Returns the data models in the current page.
getPagination()  : Pagination|false
getSort()  : Sort|false
getTotalCount()  : int
Returns the total number of data models.
prepare()  : mixed
Prepares the data models and keys.

Methods

getCount()

Returns the number of data models in the current page.

public getCount() : int

This is equivalent to count($provider->getModels()). When [[getPagination|pagination]] is false, this is the same as [[getTotalCount|totalCount]].

Return values
int

the number of data models in the current page.

getKeys()

Returns the key values associated with the data models.

public getKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>

the list of key values corresponding to [[getModels|models]]. Each data model in [[getModels|models]] is uniquely identified by the corresponding key value in this array.

getModels()

Returns the data models in the current page.

public getModels() : array<string|int, mixed>
Return values
array<string|int, mixed>

the list of data models in the current page.

getSort()

public getSort() : Sort|false
Return values
Sort|false

the sorting object. If this is false, it means the sorting is disabled.

getTotalCount()

Returns the total number of data models.

public getTotalCount() : int

When [[getPagination|pagination]] is false, this is the same as [[getCount|count]].

Return values
int

total number of possible data models.

prepare()

Prepares the data models and keys.

public prepare([bool $forcePrepare = false ]) : mixed

This method will prepare the data models and keys that can be retrieved via [[getModels()]] and [[getKeys()]].

This method will be implicitly called by [[getModels()]] and [[getKeys()]] if it has not been called before.

Parameters
$forcePrepare : bool = false

whether to force data preparation even if it has been done before.


        
On this page

Search results