Fix module domain detection in Form::getTranslationDomain()
The usage of preg_replace had two errors: 1) The regular expression was wrong 2) $matches[0] always contains the full matched string, not the first parenthesized subpattern The correct version of preg_replace would've been: if (preg_match('/^Icinga\\\\Module\\\\([A-Za-z]+)\\\\/', get_called_class(), $matches) === 1) { return strtolower($matches[1]); } But since there's no benefit of using a regular expression here except less speed, I replaced it with using explode. refs #7551
This commit is contained in:
parent
d6e331018b
commit
50bbf77d0c
|
@ -806,19 +806,20 @@ class Form extends Zend_Form
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the translation domain for this form
|
||||
* Get the translation domain for this form
|
||||
*
|
||||
* The returned translation domain is either determined based on
|
||||
* this form's class path or it is the default `icinga' domain
|
||||
* The returned translation domain is either determined based on this form's qualified name or it is the default
|
||||
* 'icinga' domain
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
protected function getTranslationDomain()
|
||||
{
|
||||
if (preg_match('@^Icinga\\\\Module\\\\([A-z]+)\\\\.*$@', get_called_class(), $matches) === 1) {
|
||||
return strtolower($matches[0]);
|
||||
$parts = explode('\\', get_called_class());
|
||||
if ($parts[1] === 'Module') {
|
||||
// Assume format Icinga\Module\ModuleName\Forms\...
|
||||
return strtolower($parts[2]);
|
||||
}
|
||||
|
||||
return 'icinga';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue