renamed IDataProvider::getItems() to getModels()

This commit is contained in:
Qiang Xue
2013-08-03 08:20:30 -04:00
parent 3d5388ff2b
commit b31b02a55d
10 changed files with 153 additions and 160 deletions

View File

@@ -112,7 +112,7 @@ class GridView extends ListViewBase
}
/**
* Renders the data items for the grid view.
* Renders the data models for the grid view.
*/
public function renderItems()
{
@@ -217,22 +217,22 @@ class GridView extends ListViewBase
*/
public function renderTableBody()
{
$items = array_values($this->dataProvider->getItems());
$models = array_values($this->dataProvider->getModels());
$keys = $this->dataProvider->getKeys();
$rows = array();
foreach ($items as $index => $item) {
foreach ($models as $index => $model) {
$key = $keys[$index];
if ($this->beforeRow !== null) {
$row = call_user_func($this->beforeRow, $item, $key, $index);
$row = call_user_func($this->beforeRow, $model, $key, $index);
if (!empty($row)) {
$rows[] = $row;
}
}
$rows[] = $this->renderTableRow($item, $key, $index);
$rows[] = $this->renderTableRow($model, $key, $index);
if ($this->afterRow !== null) {
$row = call_user_func($this->afterRow, $item, $key, $index);
$row = call_user_func($this->afterRow, $model, $key, $index);
if (!empty($row)) {
$rows[] = $row;
}
@@ -242,21 +242,21 @@ class GridView extends ListViewBase
}
/**
* Renders a table row with the given data item and key.
* @param mixed $item the data item
* @param mixed $key the key associated with the data item
* @param integer $index the zero-based index of the data item among the item array returned by [[dataProvider]].
* Renders a table row with the given data model and key.
* @param mixed $model the data model to be rendered
* @param mixed $key the key associated with the data model
* @param integer $index the zero-based index of the data model among the model array returned by [[dataProvider]].
* @return string the rendering result
*/
public function renderTableRow($item, $key, $index)
public function renderTableRow($model, $key, $index)
{
$cells = array();
/** @var \yii\widgets\grid\Column $column */
foreach ($this->columns as $column) {
$cells[] = $column->renderDataCell($item, $index);
$cells[] = $column->renderDataCell($model, $index);
}
if ($this->rowOptions instanceof Closure) {
$options = call_user_func($this->rowOptions, $item, $key, $index);
$options = call_user_func($this->rowOptions, $model, $key, $index);
} else {
$options = $this->rowOptions;
}
@@ -315,10 +315,10 @@ class GridView extends ListViewBase
protected function guessColumns()
{
$items = $this->dataProvider->getItems();
$item = reset($items);
if (is_array($item) || is_object($item)) {
foreach ($item as $name => $value) {
$models = $this->dataProvider->getModels();
$model = reset($models);
if (is_array($model) || is_object($model)) {
foreach ($model as $name => $value) {
$this->columns[] = $name;
}
} else {