Issues

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

Issue Type: Bug Created: 2009-08-21T13:20:07.000+0000 Last Updated: 2009-12-21T17:09:44.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Onno Lissenberg (orlissenberg) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Rest_Route

Related issues: Attachments:

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

Posted by Luke Crouch (lcrouch) on 2009-08-25T13:59:25.000+0000

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

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

Thanks, -L

Posted by Onno Lissenberg (orlissenberg) on 2009-09-01T00:36:08.000+0000

Seems to be resolved in the current version!

Thanks

Posted by Tim Brayshaw (twisty) on 2009-11-27T04:42:34.000+0000

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

<pre class="highlight">
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.

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

Cheers, Tim.

Posted by Luke Crouch (lcrouch) on 2009-12-21T17:09:44.000+0000

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.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts