setOptions($options); } public function __get($key) { if ('_' == $key[0]) { throw new Qs_ViewController_Exception(sprintf('Cannot retrieve value for protected/private property "%s"', $key)); } if (!isset($this->$key)) { return null; } return $this->$key; } public function __set($key, $value) { $this->setProperty($key, $value); } /** * @param mixed $translator * @return $this */ public function setTranslator($translator) { $this->_translator = $translator; return $this; } /** * @return mixed */ public function getTranslator() { return $this->_translator; } public function translate() { $args = func_get_args(); $arguments = Qs_Array::flatten($args); if (null === $this->_translator) { if (count($args) == 1) { return $args[0]; } return Qs_Translate::getPlural([$arguments[0], $arguments[1]], $arguments[2]); } return $this->_translator->translate($arguments); } public function setProperty($name, $value) { $name = (string) $name; if ('_' == $name[0]) { // Ignore protected options return $this; } if (null === $value) { unset($this->$name); } else { $this->$name = $value; } return $this; } public function setOptions($options) { foreach ($options as $key => $value) { $method = 'set' . ucfirst($key); if (method_exists($this, $method) && $key != 'options') { $this->$method($value); } else { $this->setProperty($key, $value); } } return $this; } public function setTemplatePath($templatePath) { $this->_templatePath = $templatePath; } public function getTemplate($template = null) { return Qs_SiteMap::getTemplate($template ?: $this->_template, $this->_templatePath); } }