/** * Create and add WSDL Types for complex custom attribute classes * * @param \Magento\Webapi\Model\Soap\Wsdl $wsdl * @return \Magento\Webapi\Model\Soap\Wsdl */ protected function addCustomAttributeTypes($wsdl) { foreach ($this->customAttributeTypeLocator->getAllServiceDataInterfaces() as $customAttributeClass) { $typeName = $this->_typeProcessor->register($customAttributeClass); $wsdl->addComplexType($typeName); } return $wsdl; }
/** * Retrieve method interface and documentation description. * * @param \Zend\Code\Reflection\MethodReflection $method * @return array * @throws \InvalidArgumentException */ public function extractMethodData(\Zend\Code\Reflection\MethodReflection $method) { $methodData = ['documentation' => $this->extractMethodDescription($method), 'interface' => []]; /** @var \Zend\Code\Reflection\ParameterReflection $parameter */ foreach ($method->getParameters() as $parameter) { $parameterData = ['type' => $this->_typeProcessor->register($this->_typeProcessor->getParamType($parameter)), 'required' => !$parameter->isOptional(), 'documentation' => $this->_typeProcessor->getParamDescription($parameter)]; if ($parameter->isOptional()) { $parameterData['default'] = $parameter->getDefaultValue(); } $methodData['interface']['in']['parameters'][$parameter->getName()] = $parameterData; } $returnType = $this->_typeProcessor->getGetterReturnType($method); if ($returnType != 'void' && $returnType != 'null') { $methodData['interface']['out']['parameters']['result'] = ['type' => $this->_typeProcessor->register($returnType['type']), 'documentation' => $returnType['description'], 'required' => true]; } return $methodData; }
/** * Retrieve method interface and documentation description. * * @param ReflectionMethod $method * @return array * @throws \InvalidArgumentException */ public function extractMethodData(ReflectionMethod $method) { $methodData = ['documentation' => $this->extractMethodDescription($method), 'interface' => []]; $prototypes = $method->getPrototypes(); /** Take the fullest interface that also includes optional parameters. */ /** @var \Zend\Server\Reflection\Prototype $prototype */ $prototype = end($prototypes); /** @var \Zend\Server\Reflection\ReflectionParameter $parameter */ foreach ($prototype->getParameters() as $parameter) { $parameterData = ['type' => $this->_typeProcessor->register($parameter->getType()), 'required' => !$parameter->isOptional(), 'documentation' => $parameter->getDescription()]; if ($parameter->isOptional()) { $parameterData['default'] = $parameter->getDefaultValue(); } $methodData['interface']['in']['parameters'][$parameter->getName()] = $parameterData; } if ($prototype->getReturnType() != 'void' && $prototype->getReturnType() != 'null') { $methodData['interface']['out']['parameters']['result'] = ['type' => $this->_typeProcessor->register($prototype->getReturnType()), 'documentation' => $prototype->getReturnValue()->getDescription(), 'required' => true]; } return $methodData; }