Ejemplo n.º 1
0
 private function loadUnion(SimpleType $type, DOMElement $node)
 {
     if ($node->hasAttribute("memberTypes")) {
         $types = preg_split('/\\s+/', $node->getAttribute("memberTypes"));
         foreach ($types as $typeName) {
             $type->addUnion($this->findSomething('findType', $type->getSchema(), $node, $typeName));
         }
     }
     $addCallback = function ($unType) use($type) {
         $type->addUnion($unType);
     };
     foreach ($node->childNodes as $childNode) {
         switch ($childNode->localName) {
             case 'simpleType':
                 call_user_func($this->loadSimpleType($type->getSchema(), $childNode, $addCallback));
                 break;
         }
     }
 }
Ejemplo n.º 2
0
 private function visitSimpleType(PHPClass $class, SimpleType $type)
 {
     if ($restriction = $type->getRestriction()) {
         $parent = $restriction->getBase();
         if ($parent instanceof Type) {
             $this->handleClassExtension($class, $parent);
         }
         foreach ($restriction->getChecks() as $typeCheck => $checks) {
             foreach ($checks as $check) {
                 $class->addCheck('__value', $typeCheck, $check);
             }
         }
     } elseif ($unions = $type->getUnions()) {
         $types = array();
         foreach ($unions as $i => $unon) {
             if (!$unon->getName()) {
                 $types[] = $this->visitTypeAnonymous($unon, $type->getName() . $i, $class);
             } else {
                 $types[] = $this->visitType($unon);
             }
         }
         if ($candidato = reset($types)) {
             $class->setExtends($candidato);
         }
     }
 }
Ejemplo n.º 3
0
 private function visitSimpleType(&$class, &$data, SimpleType $type, $name)
 {
     if ($restriction = $type->getRestriction()) {
         $parent = $restriction->getBase();
         if ($parent instanceof Type) {
             $this->handleClassExtension($class, $data, $parent, $name);
         }
     } elseif ($unions = $type->getUnions()) {
         foreach ($unions as $i => $unon) {
             $this->handleClassExtension($class, $data, $unon, $name . $i);
             break;
         }
     }
 }