Slide 23
Slide 23 text
Sorting
// sort=title,-publisher
case 'sort':
$parts = explode(',', $value);
foreach ($parts as $part) {
preg_match_all('/^(\-)?([\w]+)$/', $part, $matches);
if (empty($matches[0])) {
throw new \Exception('Invalid sort format.', 1);
}
$name = $matches[2][0];
$order = $matches[1][0];
$this->sort[$name] = $order;
}
break;
23