IDataProvider.php 1.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yii\data;

/**
 * IDataProvider is the interface that must be implemented by data provider classes.
 *
13 14
 * Data providers are components that sort and paginate data, and provide them to widgets
 * such as [[GridView]], [[ListView]].
15 16 17 18 19 20 21
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
interface IDataProvider
{
	/**
22 23
	 * Returns the number of data models in the current page.
	 * This is equivalent to `count($provider->getModels())`.
Qiang Xue committed
24
	 * When [[pagination]] is false, this is the same as [[totalCount]].
25
	 * @return integer the number of data models in the current page.
26
	 */
Qiang Xue committed
27
	public function getCount();
28 29

	/**
30
	 * Returns the total number of data models.
Qiang Xue committed
31
	 * When [[pagination]] is false, this is the same as [[count]].
32
	 * @return integer total number of possible data models.
33
	 */
Qiang Xue committed
34
	public function getTotalCount();
35 36

	/**
37 38
	 * Returns the data models in the current page.
	 * @return array the list of data models in the current page.
39
	 */
40
	public function getModels();
41 42

	/**
43 44
	 * Returns the key values associated with the data models.
	 * @return array the list of key values corresponding to [[models]]. Each data model in [[models]]
45 46 47 48 49 50 51 52 53 54 55 56 57 58
	 * is uniquely identified by the corresponding key value in this array.
	 */
	public function getKeys();

	/**
	 * @return Sort the sorting object. If this is false, it means the sorting is disabled.
	 */
	public function getSort();

	/**
	 * @return Pagination the pagination object. If this is false, it means the pagination is disabled.
	 */
	public function getPagination();
}