Issues

ZF-7656: Creating a rest controller automatically makes the default index controller also rest-based.

Description

if I define a rest controller from a module to be a rest route, the index controller from the module also becomes a rest controller:

Example:

$front->getRouter()->addRoute('guides::rules', new Zend_Rest_Route($front, array(),array('guides'=>array('rules'))));

This would cause the "guides" module's "index" controller to become a rest controller, unless I later override it with:

$front->getRouter()->addRoute('guides', new Zend_Controller_Router_Route('guides/', array( 'module' => 'guides', 'controller' => 'index', 'action' => 'index' )));

which is basically a patch on the wound.

Comments

Can you tell me the exact HTTP request that gave this behavior?

e.g., GET /guides/index/index ?

Thanks, -L

Seems to be resolved in the current version!

Thanks

I don't think this is resolved. Here are two tests for Zend_Rest_RouteTest (excuse the hideous method names!) to confirm...


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);
}

The first test passes, the second fails.

1) Zend_Rest_RouteTest::test_postToNonRESTfulDefaultController_moduleHasAnotherRESTfulController_noDefaultControllerInURL_returnsFalse
Failed asserting that 
Array
(
    [module] => mod
    [action] => post
    [controller] => index
)

Cheers, Tim.

I added the missing controller check in the case of default, non-URI controllers. Good catch! Thanks for posting the exact test methods too - that made it much easier to fix.