25 #require_once 'Zend/Server/Abstract.php'; 91 if (!is_string($function) && (!is_array($function) || (2 > count($function)))) {
92 #require_once 'Zend/Json/Server/Exception.php'; 96 if (!is_callable($function)) {
97 #require_once 'Zend/Json/Server/Exception.php'; 102 if (2 < func_num_args()) {
103 $argv = func_get_args();
104 $argv = array_slice($argv, 2);
107 #require_once 'Zend/Server/Reflection.php'; 108 if (is_string($function)) {
111 $class = array_shift($function);
112 $action = array_shift($function);
114 $methods = $reflection->getMethods();
117 if ($action ==
$method->getName()) {
123 $this->
fault(
'Method not found', -32601);
145 if (3 < func_num_args()) {
146 $argv = func_get_args();
147 $argv = array_slice($argv, 3);
150 #require_once 'Zend/Server/Reflection.php'; 153 foreach ($reflection->getMethods() as
$method) {
169 #require_once 'Zend/Json/Server/Error.php'; 184 #require_once 'Zend/Json/Server/Exception.php'; 215 #require_once 'Zend/Json/Server/Exception.php'; 219 foreach ($definition as $key =>
$method) {
220 $this->_table->addMethod(
$method, $key);
248 if (
null === (
$request = $this->_request)) {
249 #require_once 'Zend/Json/Server/Request/Http.php'; 274 if (
null === (
$response = $this->_response)) {
275 #require_once 'Zend/Json/Server/Response/Http.php'; 289 $this->_autoEmitResponse = (bool) $flag;
313 if (preg_match(
'/^(set|get)/',
$method, $matches)) {
315 if (
'set' == $matches[1]) {
316 $value = array_shift($args);
334 if (
null === $this->_serviceMap) {
335 #require_once 'Zend/Json/Server/Smd.php'; 349 $serviceInfo = array(
354 $serviceInfo[
'params'] =
$params;
356 if (
false !== $serviceMap->getService($serviceInfo[
'name'])) {
357 $serviceMap->removeService($serviceInfo[
'name']);
359 $serviceMap->addService($serviceInfo);
382 $defaultParams = array_slice(
$params, count($args));
383 foreach ($defaultParams as $param) {
385 if (array_key_exists(
'default', $param)) {
386 $value = $param[
'default'];
388 array_push($args,
$value);
402 foreach (
$method->getPrototypes() as $prototype) {
403 foreach ($prototype->getParameterObjects() as $key => $parameter) {
406 'type' => $parameter->getType(),
407 'name' => $parameter->getName(),
408 'optional' => $parameter->isOptional(),
410 if (
null !== ($default = $parameter->getDefaultValue())) {
411 $params[$key][
'default'] = $default;
419 $newType = $parameter->getType();
420 if (!is_array(
$params[$key][
'type'])) {
421 if (
$params[$key][
'type'] == $newType) {
428 array_push(
$params[$key][
'type'], $parameter->getType());
464 foreach (
$method->getPrototypes() as $prototype) {
465 $return[] = $prototype->getReturnType();
467 if (1 == count($return)) {
480 if (
null === $this->_smdMethods) {
481 $this->_smdMethods = array();
482 #require_once 'Zend/Json/Server/Smd.php'; 483 $methods = get_class_methods(
'Zend_Json_Server_Smd');
485 if (!preg_match(
'/^(set|get)/',
$method)) {
488 if (strstr(
$method,
'Service')) {
491 $this->_smdMethods[] =
$method;
507 return $this->
fault(
'Invalid Request', -32600);
511 return $this->
fault(
'Invalid Request', -32600);
515 if (!$this->_table->hasMethod(
$method)) {
516 return $this->
fault(
'Method not found', -32601);
520 $invocable = $this->_table->getMethod(
$method);
523 $serviceParams =
$service->getParams();
525 if (count(
$params) < count($serviceParams)) {
530 if ( is_string( key(
$params ) ) ) {
532 $callback = $invocable->getCallback();
533 if (
'function' == $callback->getType()) {
534 $reflection =
new ReflectionFunction( $callback->getFunction() );
535 $refParams = $reflection->getParameters();
538 $reflection =
new ReflectionMethod(
539 $callback->getClass(),
540 $callback->getMethod()
542 $refParams = $reflection->getParameters();
545 $orderedParams = array();
546 foreach( $reflection->getParameters() as $refParam ) {
547 if( isset(
$params[ $refParam->getName() ] ) ) {
548 $orderedParams[ $refParam->getName() ] =
$params[ $refParam->getName() ];
549 }
elseif( $refParam->isOptional() ) {
550 $orderedParams[ $refParam->getName() ] = $refParam->getDefaultValue();
553 'Method ' .
$request->getMethod() .
' is missing required parameter: ' . $refParam->getName()
562 }
catch (Exception $e) {
563 return $this->
fault($e->getMessage(), $e->getCode(), $e);
_dispatch(Zend_Server_Method_Definition $invocable, array $params)
setRequest(Zend_Json_Server_Request $request)
elseif(isset( $params[ 'redirect_parent']))
_getParams(Zend_Server_Method_Definition $method)
setResponse(Zend_Json_Server_Response $response)
_buildSignature(Zend_Server_Reflection_Function_Abstract $reflection, $class=null)
addFunction($function, $namespace='')
static reflectFunction($function, $argv=false, $namespace='')
$_option $_optionId $class
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
setAutoEmitResponse($flag)
loadFunctions($definition)
_getReturnType(Zend_Server_Method_Definition $method)
static reflectClass($class, $argv=false, $namespace='')
setClass($class, $namespace='', $argv=null)
$_overwriteExistingMethods
fault($fault=null, $code=404, $data=null)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
_addMethodServiceMap(Zend_Server_Method_Definition $method)
_getDefaultParams(array $args, array $params)