* @copyright 2012-2013 Jurian Sluiman. * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @link http://juriansluiman.nl */ namespace SlmLocale\View\Helper; use Laminas\View\Exception\RuntimeException; use Laminas\View\Helper\AbstractHelper; use Locale; use SlmLocale\Locale\Detector; class LocaleMenu extends AbstractHelper { /** * @var Detector $detector */ protected $detector; /** * Set the class to be used on the list container * * @var string || null */ protected $class; /** * Method used to construct a title for each item * * @var string || null */ protected $titleMethod = 'displayLanguage'; /** * Flag to specify specifies whether the title should be in the current locale * * @var boolean default false */ protected $titleInCurrentLocale = false; /** * Method used to construct a label for each item * * @var string || null */ protected $labelMethod = 'displayLanguage'; /** * Flag to specify specifies whether the label should be in the current locale * * @var boolean default true */ protected $labelInCurrentLocale = true; /** * Flag to specify the current locale should be omitted from the menu * * @var boolean default false */ protected $omitCurrent = false; /** * @param Detector $detector */ public function setDetector($detector) { $this->detector = $detector; } /** * @return Detector $detector */ public function getDetector() { return $this->detector; } /** * @param string $class */ public function setUlClass($class) { $this->class = $class; return $this; } /** * @return string */ public function getUlClass() { return $this->class; } /** * @param string $itemTitleMethod */ public function setTitleMethod($titleMethod) { $this->checkLocaleMethod($titleMethod); $this->titleMethod = $titleMethod; return $this; } /** * @return string */ public function getTitleMethod() { return $this->titleMethod; } /** * @param boolean $flag */ public function setTitleInCurrentLocale($flag) { $this->titleInCurrentLocale = (bool) $flag; return $this; } /** * @return boolean */ public function getTitleInCurrentLocale() { return $this->titleInCurrentLocale; } /** * @param string $labelMethod */ public function setLabelMethod($labelMethod) { $this->checkLocaleMethod($labelMethod); $this->labelMethod = $labelMethod; return $this; } /** * @return string */ public function getLabelMethod() { return $this->labelMethod; } /** * @param boolean $flag */ public function setLabelInCurrentLocale($flag) { $this->labelInCurrentLocale = (bool) $flag; return $this; } /** * @return boolean */ public function getLabelInCurrentLocale() { return $this->labelInCurrentLocale; } /** * @param boolean $omitCurrent */ public function setOmitCurrent($omitCurrent) { $this->omitCurrent = (bool) $omitCurrent; return $this; } /** * @return boolean */ public function omitCurrent() { return $this->omitCurrent; } public function __invoke() { return $this; } /** * @param array $options * @return string * @todo implement add way to completely default rendering for maximum flexibility (see Laminas\View\Helper\Navigation::renderPartial) */ public function __toString() { if (! ($detector = $this->getDetector())) { return sprintf('