Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 3918079

Browse files
committed
Extend view renderer controller fix (zendframework#440)
1 parent b9af1d7 commit 3918079

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

library/Zend/Controller/Action/Helper/ViewRenderer.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,20 @@ protected function _translateSpec(array $vars = array())
841841
$inflector = $this->getInflector();
842842
$request = $this->getRequest();
843843
$dispatcher = $this->getFrontController()->getDispatcher();
844-
$module = $dispatcher->formatModuleName($request->getModuleName());
845-
$controller = $dispatcher->formatControllerName(
846-
$request->getControllerName()
847-
);
844+
845+
// Format module name
846+
$module = $dispatcher->formatModuleName($request->getModuleName());
847+
848+
// Format controller name
849+
$filter = new Zend_Filter_Word_CamelCaseToDash();
850+
$controller = $filter->filter($request->getControllerName());
851+
$controller = $dispatcher->formatControllerName($controller);
848852
if ('Controller' == substr($controller, -10)) {
849853
$controller = substr($controller, 0, -10);
850854
}
851-
$action = $dispatcher->formatActionName($request->getActionName());
855+
856+
// Format action name
857+
$action = $dispatcher->formatActionName($request->getActionName());
852858

853859
$params = compact('module', 'controller', 'action');
854860
foreach ($vars as $key => $value) {

tests/Zend/Controller/Action/Helper/ViewRendererTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,25 @@ public function providerControllerNameDoesNotIncludeDisallowedCharacters()
938938
);
939939
}
940940

941+
/**
942+
* @group GH-440
943+
*/
944+
public function testControllerNameFormattingShouldRespectWordCamelCaseToDash()
945+
{
946+
$this->request->setControllerName('MetadataValidation')
947+
->setActionName('index');
948+
949+
$this->helper->setActionController(
950+
new Bar_IndexController(
951+
$this->request, $this->response, array()
952+
)
953+
);
954+
955+
$this->assertEquals(
956+
'metadata-validation/index.phtml', $this->helper->getViewScript()
957+
);
958+
}
959+
941960
protected function _normalizePath($path)
942961
{
943962
return str_replace(array('/', '\\'), '/', $path);

0 commit comments

Comments
 (0)