public static function dereference($string, &$config = array(), $depth = 0) { $zendAutoloader = Zend_Loader_Autoloader::getInstance(); $currentZendAutoloaderSetting = $zendAutoloader->suppressNotFoundWarnings(); $zendAutoloader->suppressNotFoundWarnings(TRUE); if ($depth > self::MAX_DEREF_DEPTH) { throw new Exepction('Model Reflection error: dereferenced too deeply.'); } $myMute = Saf_Debug::mute(); if (!array_key_exists('_lateBindingParams', $config)) { $config['_lateBindingParams'] = array(); } $supplement = Saf_Debug::isEnabled() && is_array($config) && array_key_exists('derefSource', $config) ? ' in ' . Saf_Array::extract('derefSource', $config, 'undisclosed_source') : ''; $newString = self::_encodeEscaped($string); //for ($i=0; $i < self::MAX_DEREF_DEPTH; $i++){ $startCut = strpos($newString, '[['); while ($startCut !== FALSE) { $endCut = strpos($newString, ']]', $startCut); if ($endCut !== FALSE) { $term = substr($newString, $startCut + 2, $endCut - ($startCut + 2)); try { $translatedTerm = self::translate($term, $config, $depth + 1); } catch (Exception $e) { Saf_Debug::unmute($myMute); throw $e; } $unique = strpos($term, '*') === 0; $newString = $unique ? str_replace("[[{$term}]]", $translatedTerm, $newString, $unique) : str_replace("[[{$term}]]", $translatedTerm, $newString); } else { Saf_Debug::unmute($myMute); throw new Exception("Model Reflection Error: Unterminated term {$supplemental}"); } $startCut = strpos($newString, '[[', $startCut + 2); //#TODO #2.0.0 make sure we skip anything just transplanted in } Saf_Debug::unmute($myMute); $zendAutoloader->suppressNotFoundWarnings($currentZendAutoloaderSetting); return $newString; }
public function __construct($config = array()) { //#TODO unmuddle some of this... $this->_hostId = Saf_Array::extract('hostId', $config, APPLICATION_ENV . '.' . APPLICATION_HOST); $this->_productId = Saf_Array::extract('productId', $config, APPLICATION_ID . '.' . APPLICATION_INSTANCE); $this->_baseTime = (int) Saf_Array::extract('baseTime', $config, self::$_systemBaseTime); $this->_timeInterval = (int) Saf_Array::extract('timeInterval', $config, $this->_timeInterval); $this->_method = Saf_Array::extractOptional('method', $config); $this->_id = Saf_Array::extractOptional('id', $config); switch ($this->_method) { case self::METHOD_REQUEST: $this->setMethodRequest(); break; case self::METHOD_PUBLISH: $this->setMethodPublish(); break; case self::METHOD_CANCEL: $this->setMethodCancel(); break; } if (!is_null($this->_id) && (!is_array($this->_id) || count($this->_id) > 0)) { $this->generate($config); } }