Zend Framework

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

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.1
  • Fix Version/s: 1.10.0
  • Component/s: Zend_Rest_Route
  • Labels:
    None

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.

Activity

Hide
Luke Crouch added a comment -

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

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

Thanks,
-L

Show
Luke Crouch added a comment - Can you tell me the exact HTTP request that gave this behavior? e.g., GET /guides/index/index ? Thanks, -L
Hide
Onno Lissenberg added a comment -

Seems to be resolved in the current version!

Thanks

Show
Onno Lissenberg added a comment - Seems to be resolved in the current version! Thanks
Hide
Tim Brayshaw added a comment -

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

Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
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.

Show
Tim Brayshaw added a comment - I don't think this is resolved. Here are two tests for Zend_Rest_RouteTest (excuse the hideous method names!) to confirm...
Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
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.
Hide
Luke Crouch added a comment -

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.

Show
Luke Crouch added a comment - 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.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: