public function __construct($options = array()) { if ($options instanceof Zend_Config) { $options = $options->toArray(); } else { if (!is_array($options)) { $options = func_get_args(); $temp['format'] = array_shift($options); if (!empty($options)) { $temp['locale'] = array_shift($options); } $options = $temp; } } if (array_key_exists('format', $options)) { $this->setFormat($options['format']); } if (!array_key_exists('locale', $options)) { if (Registry::isRegistered('Zend_Locale')) { $options['locale'] = Registry::get('Zend_Locale'); } } if (array_key_exists('locale', $options)) { $this->setLocale($options['locale']); } }
public function getContainer() { if (null === $this->_container) { // try to fetch from registry first if (Registry::isRegistered('Life\\Navigation')) { $nav = Registry::get('Life\\Navigation'); if ($nav instanceof Container) { return $this->_container = $nav; } } // nothing found in registry, create new container $this->_container = new Navigation(); } return $this->_container; }
/** * Finds the proper locale based on the input * Checks if it exists, degrades it when necessary * Detects registry locale and when all fails tries to detect a automatic locale * Returns the found locale as string * * @param string $locale * @throws Zend_Locale_Exception When the given locale is no locale or the autodetection fails * @return string */ public static function findLocale($locale = null) { if ($locale === null) { if (Registry::isRegistered('Locale')) { $locale = Registry::get('Locale'); } } if ($locale === null) { $locale = new Locale(); } if (!Locale::isLocale($locale, true, false)) { if (!Locale::isLocale($locale, false, false)) { $locale = Locale::getLocaleToTerritory($locale); if (empty($locale)) { throw new Exception("The locale '{$locale}' is no known locale"); } } else { $locale = new Locale($locale); } } $locale = self::_prepareLocale($locale); return $locale; }