protected function getData($key = null)
{
if (!$this->data) {
$onlyRow = $key !== null && $this->presenter->isAjax();
if (!$onlyRow && $this->paginator) {
$itemsCount = call_user_func($this->paginatorItemsCountCallback, $this->filterDataSource, $this->orderColumn ? [$this->orderColumn, strtoupper($this->orderType)] : null);
$this->paginator->setItemCount($itemsCount);
if ($this->paginator->page !== $this->page) {
$this->paginator->page = $this->page = 1;
}
}
$this->data = call_user_func($this->dataSourceCallback, $this->filterDataSource, $this->orderColumn ? [$this->orderColumn, strtoupper($this->orderType)] : null, $onlyRow ? null : $this->paginator);
}
if ($key === null) {
return $this->data;
}
foreach ($this->data as $row) {
if ($this->getter($row, $this->rowPrimaryKey) == $key) {
return $row;
}
}
throw new \Exception('Row not found');
}