/** * 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())); }
/** * Parse operation name to separate resource name from method name. * * <pre>Result format: * array( * 0 => 'resourceName', * 1 => 'methodName' * )</pre> * * @param string $operationName * @return array * @throws InvalidArgumentException In case when the specified operation name is invalid. */ protected function _parseOperationName($operationName) { /** Note that '(.*?)' must not be greedy to allow regexp to match 'multiUpdate' method before 'update' */ $regEx = sprintf('/(.*?)(%s)$/i', implode('|', Mage_Webapi_Controller_ActionAbstract::getAllowedMethods())); if (preg_match($regEx, $operationName, $matches)) { $resourceName = $matches[1]; $methodName = lcfirst($matches[2]); $result = array($resourceName, $methodName); return $result; } throw new InvalidArgumentException(sprintf('The "%s" is not a valid API resource operation name.', $operationName)); }