Permalink
Browse files

Patching up routing support.

  • Loading branch information...
1 parent 728fac9 commit 01ac59063c85e11fbb1b61ce9973e9d52eb79f68 @nateabele committed Oct 10, 2012
Showing with 5 additions and 3 deletions.
  1. +2 −2 action/Resource.php
  2. +3 −1 net/http/Resources.php
View
@@ -100,9 +100,8 @@ protected function _name() {
protected function _method($request, $params) {
$name = $this->_name();
- $badIndex = ($request->method != 'GET' && $params['action'] == 'index');
- if (($action = $params['action']) && !$badIndex) {
+ if (($action = $params['action']) && $params['action'] != 'index') {
$methods = array_diff(get_class_methods($this), get_class_methods(__CLASS__));
if (!in_array($action, $methods) || strpos($action, '_') === 0) {
@@ -229,6 +228,7 @@ public function __invoke($request, array $params = array()) {
$classes = $this->_classes;
$params = ($params ?: $request->params) + array('action' => null);
$state = $data = array();
+ $method = null;
$stateMap = array($this->_responder, 'state');
$keyMap = function($obj) { return is_object($obj) ? spl_object_hash($obj) : null; };
@@ -126,6 +126,7 @@ public static function all($resources, array $config, $request) {
if (isset($data[$name])) {
return;
}
+ $resource = is_string($resource) ? array('params' => $resource) : $resource;
$resource += compact('name') + $defaults;
$resource['binding'] = $resource[0];
unset($resource[0]);
@@ -352,7 +353,8 @@ public static function export(array $resources, array $options = array()) {
$remap[$resource] = $config;
$names[] = "[{$first}" . ucfirst($first) . "]" . substr($path, 1);
}
- $template = $options['prefix'] . '/{:controller:' . join('|', $names) . '}/{:action}';
+ $template = $options['prefix'] . '/{:controller:' . join('|', $names) . '}';
+ $template .= '/{:action:[^0-9]+}';
$template .= '/{:id:(?:[0-9a-f]{24})|(?:\d+)}'; //'.{:type}';
return static::_instance('route', compact('template') + array(

0 comments on commit 01ac590

Please sign in to comment.