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

Commit da538c1

Browse files
committed
Merge branch 'froschdesign-hotfix/440'
2 parents b9af1d7 + 5670c86 commit da538c1

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,21 @@ 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+
require_once 'Zend/Filter/Word/CamelCaseToDash.php';
850+
$filter = new Zend_Filter_Word_CamelCaseToDash();
851+
$controller = $filter->filter($request->getControllerName());
852+
$controller = $dispatcher->formatControllerName($controller);
848853
if ('Controller' == substr($controller, -10)) {
849854
$controller = substr($controller, 0, -10);
850855
}
851-
$action = $dispatcher->formatActionName($request->getActionName());
856+
857+
// Format action name
858+
$action = $dispatcher->formatActionName($request->getActionName());
852859

853860
$params = compact('module', 'controller', 'action');
854861
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)