protected static function getNSDRORMMethod(NSDRBase $nsdrBase, $key, $context, $method, $data = null) { $memcache = Zend_Registry::get('memcache'); // check to see if key exists in memcache $result = $memcache->get($key); preg_match("/(.*)\\((.*)\\)/", $method, $matches); $methodName = $matches[1]; $contextArray[$context] = array('filters' => array()); if ($result === false) { // key not found if (!strlen($method) > 0) { return array('error' => __('Invalid method')); } // extract the method context methodName($context) if (array_key_exists(2, $matches)) { // replace context with the one found on method call method(context) $methodArgs = $matches[2]; if (strlen($methodArgs) > 0 && $methodArgs[0] == '@') { $str = str_replace(',@', '&@', $methodArgs); parse_str($str, $array); foreach ($array as $k => $v) { if (get_magic_quotes_gpc()) { $v = stripslashes($v); } $key = trim(str_replace('@', '', $k)); $contextArray[$context]['filters'][$key] = trim($v); } } else { // retain the methodName(value) $contextArray[$context]['filters'][$methodArgs] = ''; } } if ($methodName == 'iterator') { $getIterMethods = array(); $getIterMethods[] = 'getIterator'; $getIterMethods[] = 'getIter'; $setFilterMethods = array(); $setFilterMethods[] = 'setFilter'; $setFilterMethods[] = 'setFilters'; foreach ($getIterMethods as $iterMethod) { if (method_exists(self::$_ORMClass, $iterMethod)) { $iter = self::$_ORMClass->{$iterMethod}(); foreach ($setFilterMethods as $filterMethod) { if (method_exists($iter, $filterMethod)) { if (!is_array($context)) { $context = array($context); } $iter->{$filterMethod}($context); return $iter; } } break; } } } $methodName[0] = strtoupper($methodName[0]); $nsdrMethodName = 'nsdr' . $methodName; // check if method prefix with nsdr exists in ORMClass if (method_exists(self::$_ORMClass, $nsdrMethodName)) { $result = self::$_ORMClass->{$nsdrMethodName}($nsdrBase, $contextArray, $data); } else { // check if method exists in NSDRBase if (method_exists($nsdrBase, $methodName)) { $result = $nsdrBase->{$methodName}($nsdrBase, $contextArray, $data); } else { // otherwise, do the ordinary routine $result = self::getNSDRMethod($nsdrBase, $key, $contextArray); } } } else { if (self::isORM($result)) { $nsdr = new NSDRDefinition(); $nsdr->populateByNamespace($key); if (strlen($nsdr->aliasFor) > 0) { self::$_ORMClass = new $result($contextArray, $key); } else { self::$_ORMClass = new $result($contextArray); } $methodName[0] = strtoupper($methodName[0]); $nsdrMethodName = 'nsdr' . $methodName; if (method_exists(self::$_ORMClass, $nsdrMethodName)) { $result = self::$_ORMClass->{$nsdrMethodName}($nsdrBase, $contextArray, $data); } } } return $result; }