Exemplo n.º 1
0
 public function addSchema(Schema $schema, $namespace = null)
 {
     if ($namespace !== null && $schema->getTargetNamespace() !== $namespace) {
         throw new SchemaException(sprintf("The target namespace ('%s') for schema, does not match the declared namespace '%s'", $schema->getTargetNamespace(), $namespace));
     }
     if ($namespace !== null) {
         $this->schemas[$namespace] = $schema;
     } else {
         $this->schemas[] = $schema;
     }
 }
 /**
  * @return \GoetasWebservices\XML\XSDReader\Schema\Schema
  */
 public function readNode(\DOMNode $node, $file = 'schema.xsd')
 {
     $this->loadedFiles[$file] = $rootSchema = new Schema();
     $rootSchema->addSchema($this->getGlobalSchema());
     $callbacks = $this->schemaNode($rootSchema, $node);
     foreach ($callbacks as $callback) {
         call_user_func($callback);
     }
     return $rootSchema;
 }
Exemplo n.º 3
0
 private function visitAttribute(&$class, Schema $schema, AttributeItem $attribute)
 {
     $property = array();
     $property["expose"] = true;
     $property["access_type"] = "public_method";
     $property["serialized_name"] = $attribute->getName();
     $property["accessor"]["getter"] = "get" . Inflector::classify($attribute->getName());
     $property["accessor"]["setter"] = "set" . Inflector::classify($attribute->getName());
     $property["xml_attribute"] = true;
     if ($alias = $this->getTypeAlias($attribute)) {
         $property["type"] = $alias;
     } elseif ($itemOfArray = $this->isArrayType($attribute->getType())) {
         if ($valueProp = $this->typeHasValue($itemOfArray, $class, 'xx')) {
             $property["type"] = "GoetasWebservices\\Xsd\\XsdToPhp\\Jms\\SimpleListOf<" . $valueProp . ">";
         } else {
             $property["type"] = "GoetasWebservices\\Xsd\\XsdToPhp\\Jms\\SimpleListOf<" . $this->findPHPName($itemOfArray) . ">";
         }
         $property["xml_list"]["inline"] = false;
         $property["xml_list"]["entry_name"] = $itemOfArray->getName();
         if ($schema->getTargetNamespace()) {
             $property["xml_list"]["entry_namespace"] = $schema->getTargetNamespace();
         }
     } else {
         $property["type"] = $this->findPHPClass($class, $attribute);
     }
     return $property;
 }
Exemplo n.º 4
0
 /**
  *
  * @return \oetas\XML\WSDLReader\Wsdl\Definitions
  */
 public function readNode(\DOMElement $node, $file = 'wsdl.xsd')
 {
     $this->loadedFiles[$file] = $rootDefinitions = new Definitions();
     $schema = new Schema();
     $schema->addSchema($this->reader->getGlobalSchema());
     $rootDefinitions->setSchema($schema);
     $callbacks = $this->rootNode($rootDefinitions, $node);
     foreach ($callbacks as $callback) {
         call_user_func($callback);
     }
     return $rootDefinitions;
 }
Exemplo n.º 5
0
 /**
  *
  * @param PHPClass $class
  * @param Schema $schema
  * @param Element $element
  * @param boolean $arrayize
  * @return \GoetasWebservices\Xsd\XsdToPhp\Structure\PHPProperty
  */
 private function visitElement(&$class, Schema $schema, ElementItem $element, $arrayize = true)
 {
     $property = array();
     $property["expose"] = true;
     $property["access_type"] = "public_method";
     $property["serialized_name"] = $element->getName();
     if ($element->getSchema()->getTargetNamespace() && ($schema->getElementsQualification() || $element instanceof Element && $element->isQualified())) {
         $property["xml_element"]["namespace"] = $element->getSchema()->getTargetNamespace();
     }
     $property["accessor"]["getter"] = "get" . Inflector::classify($element->getName());
     $property["accessor"]["setter"] = "set" . Inflector::classify($element->getName());
     $t = $element->getType();
     if ($arrayize) {
         if ($itemOfArray = $this->isArrayNestedElement($t)) {
             if (!$t->getName()) {
                 $classType = $this->visitTypeAnonymous($t, $element->getName(), $class);
             } else {
                 $classType = $this->visitType($t);
             }
             $visited = $this->visitElement($classType, $schema, $itemOfArray, false);
             $property["type"] = "array<" . $visited["type"] . ">";
             $property["xml_list"]["inline"] = false;
             $property["xml_list"]["entry_name"] = $itemOfArray->getName();
             if ($schema->getTargetNamespace()) {
                 $property["xml_list"]["namespace"] = $schema->getTargetNamespace();
             }
             return $property;
         } elseif ($itemOfArray = $this->isArrayType($t)) {
             if (!$t->getName()) {
                 $visitedType = $this->visitTypeAnonymous($itemOfArray, $element->getName(), $class);
                 if ($prop = $this->typeHasValue($itemOfArray, $class, 'xx')) {
                     $property["type"] = "array<" . $prop . ">";
                 } else {
                     $property["type"] = "array<" . key($visitedType) . ">";
                 }
             } else {
                 $this->visitType($itemOfArray);
                 $property["type"] = "array<" . $this->findPHPName($itemOfArray) . ">";
             }
             $property["xml_list"]["inline"] = false;
             $property["xml_list"]["entry_name"] = $itemOfArray->getName();
             if ($schema->getTargetNamespace()) {
                 $property["xml_list"]["namespace"] = $schema->getTargetNamespace();
             }
             return $property;
         } elseif ($this->isArrayElement($element)) {
             $property["xml_list"]["inline"] = true;
             $property["xml_list"]["entry_name"] = $element->getName();
             if ($schema->getTargetNamespace()) {
                 $property["xml_list"]["namespace"] = $schema->getTargetNamespace();
             }
             $property["type"] = "array<" . $this->findPHPClass($class, $element) . ">";
             return $property;
         }
     }
     $property["type"] = $this->findPHPClass($class, $element);
     return $property;
 }