ZF-10756: ContextSwitch::initContext('default') overwrites format-parameter
Description
Hi, in my opinion the default parameter you can set to ContextSwitch::initContext($format) should not overwrite any given format-parameter by URL.
Example:
$contextSwitch = $this->_helper->contextSwitch;
$contextSwitch->addContext('excel', array('suffix' => 'excel'));
$contextSwitch->addContext('csv', array('suffix' => 'csv'));
$contextSwitch->addActionContext('myAction', 'csv') // excel is not allowed
->initContext('excel');
If the url www.example.com/my-action/format/csv is called, I would expect that the my-action.csv.phtml is rendered. Instead the my-action.excel.phtml is rendered (if it exists), although the excel-context is not allowed to this action and the given format is csv.
The problem is in ContextSwitch line 270:
// Use provided format if passed
if (!empty($format) && $this->hasContext($format)) {
$context = $format;
}
If a default format is given ('excel' in my example), it will be used allways!
I think the block can be deleted, cause the default format is already set in line 252, when no format is specified by url.
Comments
No comments to display