/** * Get regular expression to be used for method name separation into name itself and version. * * @return string */ public function getMethodNameRegularExpression() { return sprintf('/(%s)(V\\d+)/', implode('|', Mage_Webapi_Controller_ActionAbstract::getAllowedMethods())); }
/** * Find the most appropriate version suffix for the requested action. * * If there is no action with requested version, fallback mechanism is used. * If there is no appropriate action found after fallback - exception is thrown. * * @param string $operationName * @param int $requestedVersion * @param Mage_Webapi_Controller_ActionAbstract $controllerInstance * @return string * @throws Mage_Webapi_Exception */ public function identifyVersionSuffix($operationName, $requestedVersion, $controllerInstance) { $methodName = $this->getMethodNameByOperation($operationName, $requestedVersion); $methodVersion = $requestedVersion; while ($methodVersion >= self::VERSION_MIN) { $versionSuffix = Mage_Webapi_Model_ConfigAbstract::VERSION_NUMBER_PREFIX . $methodVersion; if ($controllerInstance->hasAction($methodName . $versionSuffix)) { return $versionSuffix; } $methodVersion--; } throw new Mage_Webapi_Exception($this->_helper->__('The "%s" operation is not implemented in version %s', $operationName, $requestedVersion), Mage_Webapi_Exception::HTTP_BAD_REQUEST); }