Skip to content
This repository was archived by the owner on May 16, 2018. It is now read-only.

Extend view renderer controller fix (#440) #537

Merged
merged 2 commits into from
Mar 27, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions library/Zend/Controller/Action/Helper/ViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,20 @@ protected function _translateSpec(array $vars = array())
$inflector = $this->getInflector();
$request = $this->getRequest();
$dispatcher = $this->getFrontController()->getDispatcher();
$module = $dispatcher->formatModuleName($request->getModuleName());
$controller = $dispatcher->formatControllerName(
$request->getControllerName()
);

// Format module name
$module = $dispatcher->formatModuleName($request->getModuleName());

// Format controller name
$filter = new Zend_Filter_Word_CamelCaseToDash();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to require_once 'Zend/Filter/Word/CamelCaseToDash.php somewhere.

$controller = $filter->filter($request->getControllerName());
$controller = $dispatcher->formatControllerName($controller);
if ('Controller' == substr($controller, -10)) {
$controller = substr($controller, 0, -10);
}
$action = $dispatcher->formatActionName($request->getActionName());

// Format action name
$action = $dispatcher->formatActionName($request->getActionName());

$params = compact('module', 'controller', 'action');
foreach ($vars as $key => $value) {
Expand Down
19 changes: 19 additions & 0 deletions tests/Zend/Controller/Action/Helper/ViewRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,25 @@ public function providerControllerNameDoesNotIncludeDisallowedCharacters()
);
}

/**
* @group GH-440
*/
public function testControllerNameFormattingShouldRespectWordCamelCaseToDash()
{
$this->request->setControllerName('MetadataValidation')
->setActionName('index');

$this->helper->setActionController(
new Bar_IndexController(
$this->request, $this->response, array()
)
);

$this->assertEquals(
'metadata-validation/index.phtml', $this->helper->getViewScript()
);
}

protected function _normalizePath($path)
{
return str_replace(array('/', '\\'), '/', $path);
Expand Down