1
votes

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

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

1
Why not just use $this->url(array('action'=>'foo-bar','controller=>'my-good')); ?brady.vitrano
@brady vitrano If no other default routher doing this magic then why not zf checks for Capital letter inside there implementation of url view helper and thus create a correct url for us by default ?Mr Coder

1 Answers

1
votes

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.