Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Update Lib/Bancha/Network/BanchaRequestTransformer.php #38

Merged
merged 1 commit into from

2 participants

@sauralph

Not the most elegant solution but it fixes bug #21. The Named Parameters for ordering are called SORT and DIRECTION. The ORDER option may be used for multiple sorting only within the controller.

@rolandschuetz

I just check it, looks good.
Thanks for the fix!

@rolandschuetz rolandschuetz merged commit d6767f9 into Bancha:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 18, 2012
  1. @sauralph
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +7 −1 Lib/Bancha/Network/BanchaRequestTransformer.php
View
8 Lib/Bancha/Network/BanchaRequestTransformer.php
@@ -279,10 +279,14 @@ public function getPaging() {
unset($this->data['data'][0]['limit']);
}
$order = array();
+ $sort_field = '';
+ $direction = '';
if (isset($this->data['data'][0]) && is_array($this->data['data'][0]) && isset($this->data['data'][0]['sort'])) {
foreach ($this->data['data'][0]['sort'] as $sort) {
if (isset($sort['property']) && isset($sort['direction'])) {
- $order[$this->getController() . '.' . $sort['property']] = strtolower($sort['direction']);
+ $order[$this->getModel() . '.' . $sort['property']] = strtolower($sort['direction']);
+ $sort_field = $sort['property'];
+ $direction = $sort['direction'];
}
}
unset($this->data['data'][0]['sort']);
@@ -291,6 +295,8 @@ public function getPaging() {
'page' => $page,
'limit' => $limit,
'order' => $order,
+ 'sort' => $sort_field,
+ 'direction' => $direction
);
return $this->paginate;
}
Something went wrong with that request. Please try again.