Пример #1
0
 public function getTypeName(Type $type)
 {
     $name = $this->classify($type->getName());
     if ($name && substr($name, -4) !== 'Type' && substr($name, -5) !== 'Tipus') {
         $name .= "Type";
     }
     return $name;
 }
Пример #2
0
 public function getTypeName(Type $type)
 {
     $name = Inflector::classify($type->getName());
     if ($name && substr($name, -4) !== 'Type') {
         $name .= "Type";
     }
     return $name;
 }
Пример #3
0
 /**
  * Create a skeleton class from the given XML type
  *
  * @param Type $type
  * @return \Zend\Code\Generator\ClassGenerator
  */
 protected function createClassFromType(Type $type)
 {
     $targetNamespace = $type->getSchema()->getTargetNamespace();
     $namespace = $this->namespaceInflector->inflectNamespace($type);
     // create the class
     $class = new ClassGenerator();
     $class->setName($type->getName());
     if ($namespace) {
         $class->setNamespaceName($namespace);
     }
     // set the class documentation
     $docDescription = new Html2Text($type->getDoc());
     $doc = new DocBlockGenerator($docDescription->getText());
     $doc->setTag(new GenericTag('xmlns', $targetNamespace));
     $class->setDocBlock($doc);
     return $class;
 }
Пример #4
0
 private function findPHPName(Type $type)
 {
     $schema = $type->getSchema();
     if ($className = $this->getTypeAlias($type)) {
         if (($pos = strrpos($className, '\\')) !== false) {
             return [substr($className, $pos + 1), substr($className, 0, $pos)];
         } else {
             return [$className, null];
         }
     }
     $name = $this->getNamingStrategy()->getTypeName($type);
     if (!isset($this->namespaces[$schema->getTargetNamespace()])) {
         throw new Exception(sprintf("Can't find a PHP namespace to '%s' namespace", $schema->getTargetNamespace()));
     }
     $ns = $this->namespaces[$schema->getTargetNamespace()];
     return [$name, $ns];
 }
Пример #5
0
 /**
  * @param Type $type
  * @return \Goetas\XML\XSDReader\Schema\Element\ElementSingle|null
  */
 protected function isArrayNestedElement(Type $type)
 {
     if ($type instanceof ComplexType && !$type->getParent() && !$type->getAttributes() && count($type->getElements()) === 1) {
         $elements = $type->getElements();
         return $this->isArrayElement(reset($elements));
     }
 }
Пример #6
0
 public function addType(Type $type)
 {
     $this->types[$type->getName()] = $type;
 }
Пример #7
0
 /**
  * Determine the fully qualified name of a type from the XMLSchema for a DocBlock comment, prepending the type with
  * a '\'
  *
  * @param \Goetas\XML\XSDReader\Schema\Type\Type|\Sapone\Util\SimpleXMLElement $type
  * @return string
  */
 public function inflectDocBlockQualifiedName(Type $type)
 {
     $result = $type->getSchema()->getTargetNamespace() !== SchemaReader::XSD_NS ? '\\' : '';
     $result .= $this->inflectQualifiedName($type);
     return $result;
 }
Пример #8
0
 public function getTypeName(Type $type)
 {
     return $this->classify($type->getName()) . "Type";
 }
Пример #9
0
 public function getTypeName(Type $type)
 {
     return Inflector::classify($type->getName()) . "Type";
 }
Пример #10
0
 private function loadRestriction(Type $type, DOMElement $node)
 {
     $restriction = new Restriction();
     $type->setRestriction($restriction);
     if ($node->hasAttribute("base")) {
         $restrictedType = $this->findSomething('findType', $type->getSchema(), $node, $node->getAttribute("base"));
         $restriction->setBase($restrictedType);
     } else {
         $addCallback = function ($restType) use($restriction) {
             $restriction->setBase($restType);
         };
         foreach ($node->childNodes as $childNode) {
             switch ($childNode->localName) {
                 case 'simpleType':
                     call_user_func($this->loadSimpleType($type->getSchema(), $childNode, $addCallback));
                     break;
             }
         }
     }
     foreach ($node->childNodes as $childNode) {
         if (in_array($childNode->localName, ['enumeration', 'pattern', 'length', 'minLength', 'maxLength', 'minInclusive', 'maxInclusive', 'minExclusive', 'maxExclusive'], true)) {
             $restriction->addCheck($childNode->localName, ['value' => $childNode->getAttribute("value"), 'doc' => $this->getDocumentation($childNode)]);
         }
     }
 }
Пример #11
0
 private function findPHPName(Type $type)
 {
     $schema = $type->getSchema();
     if ($alias = $this->getTypeAlias($type, $schema)) {
         return $alias;
     }
     $ns = $this->findPHPNamespace($type);
     $name = $this->getNamingStrategy()->getTypeName($type);
     return $ns . "\\" . $name;
 }