ソースを参照

ZF-7656 add restful controller check for non-URI (default) controller

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19879 44c647ce-9c0f-0410-b52a-842ac1e357ba
lcrouch 16 年 前
コミット
37f58af7c1
2 ファイル変更23 行追加1 行削除
  1. 5 1
      library/Zend/Rest/Route.php
  2. 18 0
      tests/Zend/Rest/RouteTest.php

+ 5 - 1
library/Zend/Rest/Route.php

@@ -116,7 +116,6 @@ class Zend_Rest_Route extends Zend_Controller_Router_Route_Module
         if ($path != '') {
 
             $path = explode(self::URI_DELIMITER, $path);
-
             // Determine Module
             $moduleName = $this->_defaults[$this->_moduleKey];
             $dispatcher = $this->_front->getDispatcher();
@@ -140,6 +139,11 @@ class Zend_Rest_Route extends Zend_Controller_Router_Route_Module
                     // Controller, return false to fall back to other routes
                     return false;
                 }
+            } elseif ($this->_checkRestfulController($moduleName, $controllerName)) {
+            	$values[$this->_controllerKey] = $controllerName;
+            	$values[$this->_actionKey] = 'get';
+            } else {
+            	return false;
             }
 
             //Store path count for method mapping

+ 18 - 0
tests/Zend/Rest/RouteTest.php

@@ -416,6 +416,24 @@ class Zend_Rest_RouteTest extends PHPUnit_Framework_TestCase
         $this->assertFalse($values);
     }
 
+    public function test_postToNonRESTfulDefaultController_moduleHasAnotherRESTfulController_defaultControllerInURL_returnsFalse()
+    {
+        $request = $this->_buildRequest('POST', '/mod/index');
+        $config = array('mod'=>array('user'));
+        $values = $this->_invokeRouteMatch($request, $config);
+    
+        $this->assertFalse($values);
+    }
+
+    public function test_postToNonRESTfulDefaultController_moduleHasAnotherRESTfulController_noDefaultControllerInURL_returnsFalse()
+    {
+        $request = $this->_buildRequest('POST', '/mod');
+        $config = array('mod'=>array('user'));
+        $values = $this->_invokeRouteMatch($request, $config);
+    
+        $this->assertFalse($values);
+    }
+
     public function test_RESTfulController_PUT_user_byIdentifier()
     {
         $request = $this->_buildRequest('PUT', '/mod/user/lcrouch');