开发者

Zend framework Router replaces capital letters with dashes by default?

If we use capital alphabet in between name for zend controller and action for example inside default module we create

class MyGoodController extends Zend_Controller_Action {

public fooBarAction()
{

}

}

Than to access this action browser url looks like mysite.com/my-good/foo-bar

开发者_如何学Python

Is there any default zend router added inside zf managing this translation ? because I want to use URL view helper to generate the correct link for me which it doesnt for e.g in view

$this->url(array('action'=>'fooBar','controller=>'myGood')); 

did not produce the correct url it generates /myGood/fooBar instead of /my-good/foo-bar


As stated in the comment you need to use:

$this->url(array('action'=>'foo-bar','controller=>'my-good'));

The URL view helper assembles a link based on a route set in your application.

Routes match requests based on the URL.

It really comes down to separation of concerns. The helper is only making use of a route and again routes only deal with what is in the URL. Getting the proper class names based on a route is the dispatcher's concerns.

It's best to leave the route to deal with only what is in the URL because dispatchers can change. What might work for you using the standard dispatcher may not fit others that use a different dispatcher.

To accomplish what you're asking, you can always use a custom view helper that does the conversion for you but that is assuming you never change dispatchers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜