protected function convertParameters($firstResult, $parameters)
{
$this->firstResult = is_numeric($firstResult) ? intval($firstResult) : $this->criteria->firstResult;
$this->maxResults = isset($parameters['length']) ? intval($parameters['length']) : $this->criteria->maxResults;
$this->columns = isset($parameters['columns']) ? intval($parameters['columns']) : 0;
$name = isset($parameters['name']) ? $parameters['name'] : '';
$this->name = is_string($name) && trim($name) != '' ? $name : $this->defaultName();
$orderString = isset($parameters['order']) ? str_replace('by', '', $parameters['order']) : '';
$orderArray = $this->parseConstraintsString($orderString);
foreach (array_chunk($orderArray, 2, true) as $order) {
if (count($order) == 2) {
foreach ($this->criteria as $key => $value) {
if ($key == $order[0]) {
$this->criteria->orderBy[$order[0]] = $order[1];
}
}
}
}
// Set first and max results values to critera.
$this->criteria->firstResult = $this->firstResult;
$this->criteria->maxResults = $this->maxResults;
}