Ejemplo n.º 1
0
 /**
  * Process type name.
  * In case parameter type is a complex type (class) - process its properties.
  *
  * @param string $type
  * @return string
  */
 public function process($type)
 {
     $typeName = $this->_helper->normalizeType($type);
     if (!$this->_helper->isTypeSimple($typeName)) {
         $complexTypeName = $this->_helper->translateTypeName($type);
         if (!isset($this->_types[$complexTypeName])) {
             $this->_processComplexType($type);
             if (!$this->_helper->isArrayType($complexTypeName)) {
                 $this->_typeToClassMap[$complexTypeName] = $type;
             }
         }
         $typeName = $complexTypeName;
     }
     return $typeName;
 }
Ejemplo n.º 2
0
 /**
  * Format $data according to specified $dataType recursively.
  *
  * Instantiate objects of proper classes and set data to its fields.
  *
  * @param mixed $data
  * @param string $dataType
  * @param Mage_Webapi_Model_ConfigAbstract $apiConfig
  * @return mixed
  * @throws LogicException If specified $dataType is invalid
  * @throws Mage_Webapi_Exception If required fields do not have values specified in $data
  */
 protected function _formatParamData($data, $dataType, Mage_Webapi_Model_ConfigAbstract $apiConfig)
 {
     if ($this->_configHelper->isTypeSimple($dataType) || is_null($data)) {
         $formattedData = $data;
     } elseif ($this->_configHelper->isArrayType($dataType)) {
         $formattedData = $this->_formatArrayData($data, $dataType, $apiConfig);
     } else {
         $formattedData = $this->_formatComplexObjectData($data, $dataType, $apiConfig);
     }
     return $formattedData;
 }
Ejemplo n.º 3
0
 /**
  * Process array of types.
  *
  * @param string $type
  * @param array $callInfo
  */
 protected function _processArrayParameter($type, $callInfo = array())
 {
     $arrayItemType = $this->_helper->getArrayItemType($type);
     $arrayTypeName = $this->_helper->translateArrayTypeName($type);
     if (!$this->_helper->isTypeSimple($arrayItemType)) {
         $this->addComplexType($arrayItemType, $callInfo);
     }
     $arrayTypeParameters = array(self::ARRAY_ITEM_KEY_NAME => array('type' => $arrayItemType, 'required' => false, 'isArray' => true, 'documentation' => sprintf('An item of %s.', $arrayTypeName)));
     $arrayTypeData = array('documentation' => sprintf('An array of %s items.', $arrayItemType), 'parameters' => $arrayTypeParameters);
     $this->_config->setTypeData($arrayTypeName, $arrayTypeData);
     $this->addComplexType($arrayTypeName, $callInfo);
 }
Ejemplo n.º 4
0
 /**
  * Assert parameter data.
  *
  * @param string $expectedName
  * @param string $expectedType
  * @param string $expectedIsRequired
  * @param string $expectedDoc
  * @param array $expectedAppinfo
  * @param DOMElement $complexType with actual parameter element.
  */
 protected function _assertParameter($expectedName, $expectedType, $expectedIsRequired, $expectedDoc, $expectedAppinfo, DOMElement $complexType)
 {
     $xsdNs = Wsdl::XSD_NS;
     $tns = Wsdl::TYPES_NS;
     /** @var DOMElement $parameterElement */
     $parameterElement = $this->_xpath->query("{$xsdNs}:sequence/{$xsdNs}:element[@name='{$expectedName}']", $complexType)->item(0);
     $this->assertNotNull($parameterElement, sprintf('"%s" element was not found in complex type "%s".', $expectedName, $complexType->getAttribute('name')));
     $isArray = $this->_helper->isArrayType($expectedType);
     if ($isArray) {
         $expectedType = $this->_helper->translateArrayTypeName($expectedType);
     } else {
         $this->assertEquals($expectedIsRequired ? 1 : 0, $parameterElement->getAttribute('minOccurs'));
         $this->assertEquals(1, $parameterElement->getAttribute('maxOccurs'));
     }
     $expectedNs = $this->_helper->isTypeSimple($expectedType) ? $xsdNs : $tns;
     $this->assertEquals("{$expectedNs}:{$expectedType}", $parameterElement->getAttribute('type'));
     $this->_assertDocumentation($expectedDoc, $parameterElement);
     $this->_assertAppinfo($expectedAppinfo, $parameterElement);
 }
Ejemplo n.º 5
0
 /**
  * Process call info data from interface.
  *
  * @param array $interface
  * @param string $resourceName
  * @param string $methodName
  */
 protected function _processInterfaceCallInfo($interface, $resourceName, $methodName)
 {
     foreach ($interface as $direction => $interfaceData) {
         $direction = $direction == 'in' ? 'requiredInput' : 'returned';
         foreach ($interfaceData['parameters'] as $parameterData) {
             $parameterType = $parameterData['type'];
             if (!$this->_helper->isTypeSimple($parameterType)) {
                 $operation = $this->getOperationName($resourceName, $methodName);
                 if ($parameterData['required']) {
                     $condition = $direction == 'requiredInput' ? 'yes' : 'always';
                 } else {
                     $condition = $direction == 'requiredInput' ? 'no' : 'conditionally';
                 }
                 $callInfo = array();
                 $callInfo[$direction][$condition]['calls'][] = $operation;
                 $this->_apiConfig->setTypeData($parameterType, array('callInfo' => $callInfo));
             }
         }
     }
 }