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
Posted by Carlton Gibson (carlton) on 2008-01-19T07:44:10.000+0000
I looked into this briefly. This is not a solution but a possible line of enquiry:
[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...
Posted by Matthew Weier O'Phinney (matthew) on 2008-02-04T15:31:00.000+0000
Assigning to Ralph
Posted by Matthew Weier O'Phinney (matthew) on 2008-02-14T11:22:34.000+0000
Upgrading status to must have for 1.5
Posted by Ralph Schindler (ralph) on 2008-02-19T15:20:34.000+0000
Please check revision 8177 for a fix.
-ralph
Posted by Ralph Schindler (ralph) on 2008-02-20T08:56:25.000+0000
If there are any issues here, please reopen.
-ralph