Issues

ZF-2443: ViewRenderer's setViewBasePathSpec() does not recognize the placeholders :module, :controller or :action

Description

When changing the default script path using Zend_Controller_Action_Helper_ViewRenderer::setViewBasePathSpec(), the placeholders :module, :controller and :action are not recognized by the inflector.

Code:

$vr = $this->_helper->viewRenderer;
$vr->setView($this->view)
     ->setViewBasePathSpec(':moduleDir/:module')
     ->initView();

Exception thrown: Fatal error: Uncaught exception 'Zend_Filter_Exception' with message 'A replacement identifier : was found inside the inflected target, perhaps a rule was not satisfied with a target source? Unsatisfied inflected target: /data/W/mvc.vilagenet.com.br/application/modules/:module' in /data/W/mvc.vilagenet.com.br/library/Zend/Filter/Inflector.php:454 Stack trace:

0 /data/W/mvc.vilagenet.com.br/library/Zend/Controller/Action/Helper/ViewRenderer.php(363): Zend_Filter_Inflector->filter(Array)

1 /data/W/mvc.vilagenet.com.br/library/Zend/Controller/Action/Helper/ViewRenderer.php(438): Zend_Controller_Action_Helper_ViewRenderer->_getBasePath()

2 /data/W/mvc.vilagenet.com.br/library/Vilage/Controller/Action.php(30): Zend_Controller_Action_Helper_ViewRenderer->initView()

3 /data/W/mvc.vilagenet.com.br/library/Zend/Controller/Action.php(129): Vilage_Controller_Action->init()

4 /data/W/mvc.vilagenet.com.br/library/Zend/Controller/Dispatcher/Standard.php(218): Zend_Controller_Action->__construct(Object(Zend_Controller_Request_Http in /data/W/mvc.vilagenet.com.br/library/Zend/Filter/Inflector.php on line 454

I´m using the snapshot ZendFramework-20080117-7469.

Comments

I looked into this briefly. This is not a solution but a possible line of enquiry:

From r7089, in ViewRenderer::_getBasePath() an empty array is passed to the inflector's filter method:

[Lines 360 -363 : ViewRenderer::_getBasePath()] $inflector = $this->getInflector(); $this->_setInflectorTarget($this->getViewBasePathSpec()); $path = $inflector->filter(array()); return $path;

Should it not pass $this->_inflectorTarget instead?

From Zend/Filter/Inflector.php:

Inflector::filter() begins with a foreach on the passed array, which isn't going to get very far if that is empty...

Assigning to Ralph

Upgrading status to must have for 1.5

Please check revision 8177 for a fix.

-ralph

If there are any issues here, please reopen.

-ralph