public function mapOptions(ModelCriteria $query, $options = array())
{
if (isset($options['limit'])) {
$query->limit($options['limit']);
}
if (isset($options['offset'])) {
$query->offset($options['offset']);
}
if (isset($options['order']) && is_array($options['order'])) {
foreach ($options['order'] as $field => $direction) {
$fieldName = ucfirst($field);
$tableMap = $this->tableMap;
if (false !== ($pos = strpos($field, '.'))) {
$relationName = ucfirst(substr($field, 0, $pos));
$fieldName = ucfirst(substr($field, $pos + 1));
if (!($relation = $this->tableMap->getRelation($relationName))) {
throw new FileNotFoundException(sprintf('Relation `%s` in object `%s` not found', $relationName, $this->getObjectKey()));
}
$tableMap = $relation->getForeignTable();
}
if ($tableMap->hasColumnByPhpName(ucfirst($fieldName))) {
$column = $this->tableMap->getColumnByPhpName(ucfirst($fieldName));
$query->orderBy($column->getName(), $direction);
}
}
}
}