9 use Zend\Soap\Wsdl\ComplexTypeStrategy\AbstractComplexTypeStrategy;
45 $this->_typeProcessor = $typeProcessor;
55 return $this->getContext()->toDomDocument();
68 if (($soapType = $this->scanRegisteredTypes(
$type)) !==
null) {
71 $soapType = Wsdl::TYPES_NS .
':' .
$type;
73 $this->getContext()->addType(
$type, $soapType);
74 $complexType = $this->
_getDom()->createElement(Wsdl::XSD_NS .
':complexType');
75 $complexType->setAttribute(
'name',
$type);
76 $typeData = $this->_typeProcessor->getTypeData(
$type);
77 if (isset($typeData[
'documentation'])) {
78 $this->
addAnnotation($complexType, $typeData[
'documentation']);
81 if (isset($typeData[
'parameters']) && is_array($typeData[
'parameters'])) {
82 $callInfo = isset($typeData[
'callInfo']) ? $typeData[
'callInfo'] : $parentCallInfo;
84 $complexType->appendChild($sequence);
87 $this->getContext()->getSchema()->appendChild($complexType);
100 $sequence = $this->
_getDom()->createElement(Wsdl::XSD_NS .
':sequence');
101 foreach ($parameters as $parameterName => $parameterData) {
102 $parameterType = $parameterData[
'type'];
104 $element->setAttribute(
'name', $parameterName);
105 $isRequired = isset($parameterData[
'required']) && $parameterData[
'required'];
106 $default = isset($parameterData[
'default']) ? $parameterData[
'default'] :
null;
109 if ($this->_typeProcessor->isArrayType($parameterType)) {
113 Wsdl::TYPES_NS .
':' . $this->_typeProcessor->translateArrayTypeName($parameterType)
116 $element->setAttribute(
'minOccurs', 0);
141 $element->setAttribute(
'minOccurs', $isRequired ? 1 : 0);
142 $maxOccurs = isset($parameterData[
'isArray']) && $parameterData[
'isArray'] ?
'unbounded' : 1;
143 $element->setAttribute(
'maxOccurs', $maxOccurs);
144 if ($this->_typeProcessor->isTypeSimple($parameterType) || $this->_typeProcessor->isTypeAny($parameterType)) {
145 $typeNs = Wsdl::XSD_NS;
147 $typeNs = Wsdl::TYPES_NS;
150 $element->setAttribute(
'type', $typeNs .
':' . $parameterType);
162 $arrayItemType = $this->_typeProcessor->getArrayItemType(
$type);
163 $arrayTypeName = $this->_typeProcessor->translateArrayTypeName(
$type);
164 if (!$this->_typeProcessor->isTypeSimple($arrayItemType) && !$this->_typeProcessor->isTypeAny($arrayItemType)) {
167 $arrayTypeParameters = [
168 self::ARRAY_ITEM_KEY_NAME => [
169 'type' => $arrayItemType,
172 'documentation' => sprintf(
'An item of %s.', $arrayTypeName),
176 'documentation' => sprintf(
'An array of %s items.', $arrayItemType),
177 'parameters' => $arrayTypeParameters,
179 $this->_typeProcessor->setTypeData($arrayTypeName, $arrayTypeData);
193 if (isset($callInfo[
'requiredInput'][
'yes'])) {
194 $callInfo[
'requiredInput'][
'no'][
'calls'] = $callInfo[
'requiredInput'][
'yes'][
'calls'];
195 unset($callInfo[
'requiredInput'][
'yes']);
197 if (isset($callInfo[
'returned'][
'always'])) {
198 $callInfo[
'returned'][
'conditionally'][
'calls'] = $callInfo[
'returned'][
'always'][
'calls'];
199 unset($callInfo[
'returned'][
'always']);
218 $annotationNode = $this->
_getDom()->createElement(Wsdl::XSD_NS .
':annotation');
221 $appInfoNode = $this->
_getDom()->createElement(Wsdl::XSD_NS .
':appinfo');
222 $appInfoNode->setAttributeNS(
224 Wsdl::XML_NS .
':' . self::APP_INF_NS,
225 $this->getContext()->getTargetNamespace()
231 if (preg_match_all(
'/{([a-z]+):(.+)}/Ui', $documentation, $matches)) {
232 $count = count($matches[0]);
234 $appinfoTag = $matches[0][
$i];
235 $tagName = $matches[1][
$i];
236 $tagValue = $matches[2][
$i];
239 $callInfoRegExp =
'/([a-z].+):(returned|requiredInput):(yes|no|always|conditionally)/i';
240 if (preg_match($callInfoRegExp, $tagValue)) {
241 list($callName, $direction, $condition) = explode(
':', $tagValue);
242 $condition = strtolower($condition);
243 if (preg_match(
'/allCallsExcept\(([a-zA-Z].+)\)/', $callName, $calls)) {
244 $callInfo[$direction][$condition] = [
245 'allCallsExcept' => $calls[1],
247 }
elseif (!isset($callInfo[$direction][$condition][
'allCallsExcept'])) {
249 $callInfo[$direction][$condition][
'calls'][] = $callName;
256 case 'docInstructions':
260 $nodeValue = trim($tagValue);
261 $simpleTextNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':' . $tagName);
262 $simpleTextNode->appendChild($this->
_getDom()->createTextNode($nodeValue));
263 $appInfoNode->appendChild($simpleTextNode);
266 $documentation = str_replace($appinfoTag,
'', $documentation);
270 $documentationNode = $this->
_getDom()->createElement(Wsdl::XSD_NS .
':documentation');
271 $documentationText = trim($documentation);
272 $documentationNode->appendChild($this->
_getDom()->createTextNode($documentationText));
273 $annotationNode->appendChild($documentationNode);
274 $annotationNode->appendChild($appInfoNode);
275 $element->appendChild($annotationNode);
288 if ($elementType ==
'int') {
292 if ($elementType ==
'string') {
296 if ($this->_typeProcessor->isArrayType($elementType)) {
297 $natureOfTypeNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':natureOfType');
298 $natureOfTypeNode->appendChild($this->
_getDom()->createTextNode(
'array'));
299 $appInfoNode->appendChild($natureOfTypeNode);
313 if ($elementType ==
'boolean') {
314 $default = (bool)$default ?
'true' :
'false';
317 $defaultNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':default');
318 $defaultNode->appendChild($this->
_getDom()->createTextNode($default));
319 $appInfoNode->appendChild($defaultNode);
333 if (
$element->hasAttribute(
'type')) {
334 list($typeNs, $elementType) = explode(
':',
$element->getAttribute(
'type'));
349 if (!preg_match(
"/{{$annotation}:.+}/Ui", $documentation)) {
350 $annotationNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':' . $annotation);
351 $appInfoNode->appendChild($annotationNode);
364 if (!empty($callInfo)) {
365 foreach ($callInfo as $direction => $conditions) {
366 foreach ($conditions as $condition =>
$info) {
367 $callInfoNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':callInfo');
368 if (isset(
$info[
'allCallsExcept'])) {
369 $allExceptNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':allCallsExcept');
370 $allExceptNode->appendChild($this->
_getDom()->createTextNode(
$info[
'allCallsExcept']));
371 $callInfoNode->appendChild($allExceptNode);
373 foreach (
$info[
'calls'] as $callName) {
374 $callNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':callName');
375 $callNode->appendChild($this->
_getDom()->createTextNode($callName));
376 $callInfoNode->appendChild($callNode);
379 $directionNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':' . $direction);
380 $directionNode->appendChild($this->
_getDom()->createTextNode(ucfirst($condition)));
381 $callInfoNode->appendChild($directionNode);
382 $appInfoNode->appendChild($callInfoNode);
397 if (preg_match(
'/(input|output):(.+)/', $tagValue, $docMatches)) {
398 $docInstructionsNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':docInstructions');
399 $directionNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':' . $docMatches[1]);
400 $directionValueNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':' . $docMatches[2]);
401 $directionNode->appendChild($directionValueNode);
402 $docInstructionsNode->appendChild($directionNode);
403 $appInfoNode->appendChild($docInstructionsNode);
416 if (preg_match(
'|([http://]?.+):(.+):(.+)|i', $tagValue, $matches)) {
417 $seeLink = [
'url' => $matches[1],
'title' => $matches[2],
'for' => $matches[3]];
418 $seeLinkNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':seeLink');
419 foreach ([
'url',
'title',
'for'] as $subNodeName) {
420 if (isset($seeLink[$subNodeName])) {
421 $seeLinkSubNode = $this->
_getDom()->createElement(self::APP_INF_NS .
':' . $subNodeName);
422 $seeLinkSubNode->appendChild($this->
_getDom()->createTextNode($seeLink[$subNodeName]));
423 $seeLinkNode->appendChild($seeLinkSubNode);
426 $appInfoNode->appendChild($seeLinkNode);
439 foreach ($callInfo as $direction => &$callInfoData) {
440 foreach ($callInfoData as $condition => &
$data) {
441 if (isset(
$data[
'calls'])) {
442 $foundCallNameIndex = array_search($callName,
$data[
'calls']);
443 if ($foundCallNameIndex !==
false) {
444 unset(
$data[
'calls'][$foundCallNameIndex]);
445 if (empty(
$data[
'calls'])) {
446 unset($callInfo[$direction][$condition]);
addAnnotation(\DOMElement $element, $documentation, $default=null, $callInfo=[])
__construct(\Magento\Framework\Reflection\TypeProcessor $typeProcessor)
elseif(isset( $params[ 'redirect_parent']))
addComplexType($type, $parentCallInfo=[])
const ARRAY_ITEM_KEY_NAME
_processParameter(\DOMElement $element, $isRequired, $parameterData, $parameterType, $callInfo)
_processDefaultValueAnnotation($elementType, $default, \DOMElement $appInfoNode)
_processRequiredAnnotation($annotation, $documentation, \DOMElement $appInfoNode)
_processCallInfo(\DOMElement $appInfoNode, $callInfo)
_processParameters($parameters, $callInfo)
_processDocInstructions(\DOMElement $appInfoNode, $tagValue)
_overrideCallInfoName(&$callInfo, $callName)
_processElementType($elementType, $documentation, \DOMElement $appInfoNode)
_processArrayParameter($type, $callInfo=[])
_revertRequiredCallInfo($isRequired, &$callInfo)
_processSeeLink(\DOMElement $appInfoNode, $tagValue)
foreach( $_productCollection as $_product)() ?>" class $info
_getElementType(\DOMElement $element)