Inheritance | yii\data\BaseDataProvider » yii\base\Component » yii\base\Object |
---|---|
Implements | yii\base\Configurable, yii\data\DataProviderInterface |
Subclasses | yii\data\ActiveDataProvider, yii\data\ArrayDataProvider, yii\data\SqlDataProvider, yii\debug\models\timeline\DataProvider, yii\elasticsearch\ActiveDataProvider, yii\sphinx\ActiveDataProvider |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/data/BaseDataProvider.php |
BaseDataProvider provides a base class that implements the yii\data\DataProviderInterface.
For more details and usage information on BaseDataProvider, see the guide article on data providers.
Property | Type | Description | Defined By |
---|---|---|---|
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component | yii\base\Component |
$count | integer | The number of data models in the current page. | yii\data\BaseDataProvider |
$id | string | An ID that uniquely identifies the data provider among all data providers. | yii\data\BaseDataProvider |
$keys | array | The list of key values corresponding to $models. | yii\data\BaseDataProvider |
$models | array | The list of data models in the current page. | yii\data\BaseDataProvider |
$pagination | yii\data\Pagination|false | The pagination object. | yii\data\BaseDataProvider |
$sort | yii\data\Sort|boolean | The sorting object. | yii\data\BaseDataProvider |
$totalCount | integer | Total number of possible data models. | yii\data\BaseDataProvider |
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Object |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\Object |
__get() | Returns the value of an object property. | yii\base\Object |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Object |
__set() | Sets value of an object property. | yii\base\Object |
__unset() | Sets an object property to null. | yii\base\Object |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Object |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Object |
className() | Returns the fully qualified name of this class. | yii\base\Object |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getCount() | Returns the number of data models in the current page. | yii\data\BaseDataProvider |
getKeys() | Returns the key values associated with the data models. | yii\data\BaseDataProvider |
getModels() | Returns the data models in the current page. | yii\data\BaseDataProvider |
getPagination() | Returns the pagination object used by this data provider. | yii\data\BaseDataProvider |
getSort() | Returns the sorting object used by this data provider. | yii\data\BaseDataProvider |
getTotalCount() | Returns the total number of data models. | yii\data\BaseDataProvider |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Object |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\Object |
init() | Initializes the object. | yii\data\BaseDataProvider |
off() | Detaches an existing event handler from this component. | yii\base\Component |
on() | Attaches an event handler to an event. | yii\base\Component |
prepare() | Prepares the data models and keys. | yii\data\BaseDataProvider |
refresh() | Refreshes the data provider. | yii\data\BaseDataProvider |
setKeys() | Sets the key values associated with the data models. | yii\data\BaseDataProvider |
setModels() | Sets the data models in the current page. | yii\data\BaseDataProvider |
setPagination() | Sets the pagination for this data provider. | yii\data\BaseDataProvider |
setSort() | Sets the sort definition for this data provider. | yii\data\BaseDataProvider |
setTotalCount() | Sets the total number of data models. | yii\data\BaseDataProvider |
trigger() | Triggers an event. | yii\base\Component |
Method | Description | Defined By |
---|---|---|
prepareKeys() | Prepares the keys associated with the currently available data models. | yii\data\BaseDataProvider |
prepareModels() | Prepares the data models that will be made available in the current page. | yii\data\BaseDataProvider |
prepareTotalCount() | Returns a value indicating the total number of data models in this data provider. | yii\data\BaseDataProvider |
The number of data models in the current page.
public integer getCount ( )
An ID that uniquely identifies the data provider among all data providers. Generated automatically the following way in case it is not set:
public string $id = null
The list of key values corresponding to $models. Each data model in $models is uniquely identified by the corresponding key value in this array.
public array getKeys ( )
public void setKeys ( $keys )
The list of data models in the current page.
public array getModels ( )
public void setModels ( $models )
The pagination object. If this is false, it means the pagination is disabled.
public yii\data\Pagination|false getPagination ( )
public void setPagination ( $value )
The sorting object. If this is false, it means the sorting is disabled.
public yii\data\Sort|boolean getSort ( )
public void setSort ( $value )
Total number of possible data models.
public integer getTotalCount ( )
public void setTotalCount ( $value )
Returns the number of data models in the current page.
public integer getCount ( ) | ||
---|---|---|
return | integer |
The number of data models in the current page. |
Returns the key values associated with the data models.
public array getKeys ( ) | ||
---|---|---|
return | array |
The list of key values corresponding to $models. Each data model in $models is uniquely identified by the corresponding key value in this array. |
Returns the data models in the current page.
public array getModels ( ) | ||
---|---|---|
return | array |
The list of data models in the current page. |
Returns the pagination object used by this data provider.
Note that you should call prepare() or getModels() first to get correct values of yii\data\Pagination::$totalCount and yii\data\Pagination::$pageCount.
public yii\data\Pagination|false getPagination ( ) | ||
---|---|---|
return | yii\data\Pagination|false |
The pagination object. If this is false, it means the pagination is disabled. |
Returns the sorting object used by this data provider.
public yii\data\Sort|boolean getSort ( ) | ||
---|---|---|
return | yii\data\Sort|boolean |
The sorting object. If this is false, it means the sorting is disabled. |
Returns the total number of data models.
When $pagination is false, this returns the same value as $count. Otherwise, it will call prepareTotalCount() to get the count.
public integer getTotalCount ( ) | ||
---|---|---|
return | integer |
Total number of possible data models. |
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
public void init ( ) |
---|
Prepares the data models and keys.
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.
public void prepare ( $forcePrepare = false ) | ||
---|---|---|
$forcePrepare | boolean |
Whether to force data preparation even if it has been done before. |
Prepares the keys associated with the currently available data models.
protected abstract array prepareKeys ( $models ) | ||
---|---|---|
$models | array |
The available data models |
return | array |
The keys |
Prepares the data models that will be made available in the current page.
protected abstract array prepareModels ( ) | ||
---|---|---|
return | array |
The available data models |
Returns a value indicating the total number of data models in this data provider.
protected abstract integer prepareTotalCount ( ) | ||
---|---|---|
return | integer |
Total number of data models in this data provider. |
Refreshes the data provider.
After calling this method, if getModels(), getKeys() or getTotalCount() is called again, they will re-execute the query and return the latest data available.
public void refresh ( ) |
---|
Sets the key values associated with the data models.
public void setKeys ( $keys ) | ||
---|---|---|
$keys | array |
The list of key values corresponding to $models. |
Sets the data models in the current page.
public void setModels ( $models ) | ||
---|---|---|
$models | array |
The models in the current page |
Sets the pagination for this data provider.
public void setPagination ( $value ) | ||
---|---|---|
$value | array|yii\data\Pagination|boolean |
The pagination to be used by this data provider. This can be one of the following:
|
throws | yii\base\InvalidParamException |
Sets the sort definition for this data provider.
public void setSort ( $value ) | ||
---|---|---|
$value | array|yii\data\Sort|boolean |
The sort definition to be used by this data provider. This can be one of the following:
|
throws | yii\base\InvalidParamException |
Sets the total number of data models.
public void setTotalCount ( $value ) | ||
---|---|---|
$value | integer |
The total number of data models. |
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-data-basedataprovider.html