Skip to content

Commit fe94098

Browse files
author
Jurian Sluiman
committed
Merge pull request #36 from basz/fix-menu-helper-call-method
fixes overwriting of call
2 parents 87abbae + 52be614 commit fe94098

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/SlmLocale/View/Helper/LocaleMenu.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ public function __toString()
244244
$labelLocale = $this->getLabelInCurrentLocale() ? $locale : $current;
245245

246246
$url = $this->getView()->localeUrl($locale);
247-
$title = $this->callLocale($this->getTitleMethod(), $locale, $titleLocale);
248-
$label = $this->callLocale($this->getLabelMethod(), $locale, $labelLocale);
247+
$title = $this->getLocaleProperty($this->getTitleMethod(), $locale, $titleLocale);
248+
$label = $this->getLocaleProperty($this->getLabelMethod(), $locale, $labelLocale);
249249

250250
$item = sprintf(
251251
'<li><a href="%s" title="%s"%s>%s</a></li>' . "\n",
@@ -297,16 +297,24 @@ protected function checkLocaleMethod($method)
297297
}
298298
}
299299

300-
protected function callLocale($method, $locale, $in_locale = false)
300+
/**
301+
* Retrieves a value by property from Locale
302+
*
303+
* @param $property
304+
* @param $locale
305+
* @param bool $in_locale
306+
* @return mixed
307+
*/
308+
protected function getLocaleProperty($property, $locale, $in_locale = false)
301309
{
302-
$method = sprintf('\Locale::get%s', ucfirst($method));
310+
$callback = sprintf('\Locale::get%s', ucfirst($property));
303311

304312
$args = array($locale);
305313

306-
if ($in_locale && !in_array($method, array('primaryLanguage', 'region', 'script'))) {
314+
if ($in_locale && !in_array($property, array('primaryLanguage', 'region', 'script'))) {
307315
$args[] = $in_locale;
308316
}
309317

310-
return call_user_func_array($method, $args);
318+
return call_user_func_array($callback, $args);
311319
}
312320
}

0 commit comments

Comments
 (0)