Hi,

I'm just trying to integrate some view scripts and I am running into problems when creating the folder structure.

I have a custom dispatcher which changes the class structure of the controllers to better suit my file layout and autoloading infrastructure.

In the ViewRenderer.php file there is the function:
 protected function _translateSpec(array $vars = array())
 {
   ...
$controller = substr($dispatcher->formatControllerName($request->getControllerName()), 0, -10);
   ...
 }

I have to ask why there is a hard-coded 10 character name there for the view folder name, based on the dispatcher-formatted class name?

In my example I have a controller name of "Controller_Index", this is converted to "Contro", by the above line, and ultimately to "contro" later on.

Obviously this code is assuming the "Controller" suffix on Controller names, but with a custom dispatcher this may not be the case.


This assumption is not documented in the:
http://www.framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.viewrenderer

which talks about the conventions surrounding the automatic conversions:

":controller: MixedCase and camelCasedWords are separated by dashes; underscores are converted to directory separators, and the entire string cast to lower case. Examples: "FooBar" becomes "foo-bar"; "FooBar_Admin" becomes "foo-bar/admin".

Internally, the inflector uses the filters Zend_Filter_Word_CamelCaseToDash, Zend_Filter_Word_UnderscoreToSeparator, and Zend_Filter_StringToLower.
"


I appreciate I can set a custom inflector, but this shouldn't really have to be done and this substr should not be hard coded... In my case I want to strip off 11 characters from the front of my formatted controller name!

Perhaps the dispatcher should have another method called:
formatControllerNameForView() that (by default) does the substr(..., 0, 10) and which can be overwridden in a custom dispatcher?

I need to implement a solution here, so I'd like to know the right approach to take, so the patch can go upstream.

I could work around the problem with a custome inflector but I figure I may as well fix the root cause which is clearly a bug.

Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

Reply via email to