protected function convert(AbstractConverter $converter, array $schemas, array $targets, OutputInterface $output) { $generator = new ClassGenerator(); $generator->setTargetPhpVersion($converter->getTargetPhpVersion()); $generator->setBaseClass($converter->getBaseClass()); $pathGenerator = new Psr4PathGenerator($targets); $progress = $this->getHelperSet()->get('progress'); $items = $converter->convert($schemas); $progress->start($output, count($items)); foreach ($items as $item) { $progress->advance(1, true); $output->write(" Creating <info>" . $output->getFormatter()->escape($item->getFullName()) . "</info>... "); $path = $pathGenerator->getPath($item); $fileGen = new FileGenerator(); $fileGen->setFilename($path); $classGen = new \Zend\Code\Generator\ClassGenerator(); if ($generator->generate($classGen, $item)) { $fileGen->setClass($classGen); $fileGen->write(); $output->writeln("done."); } else { $output->write("skip."); } } $progress->finish(); }
protected function convert(AbstractConverter $converter, array $schemas, array $targets, OutputInterface $output) { $generator = new ClassGenerator(); $pathGenerator = new Psr4PathGenerator($targets); $progress = $this->getHelperSet()->get('progress'); $converter->addAliasMap('http://schemas.microsoft.com/exchange/services/2006/types', 'Or', function ($type) use($schemas) { return "OrElement"; }); $converter->addAliasMap('http://schemas.microsoft.com/exchange/services/2006/types', 'And', function ($type) use($schemas) { return "AndElement"; }); $converter->addAliasMap('http://schemas.microsoft.com/exchange/services/2006/types', 'EmailAddress', function ($type) use($schemas) { return "jamesiarmes\\PEWS\\API\\Type\\EmailAddressType"; }); $items = $converter->convert($schemas); $progress->start($output, count($items)); $classMap = []; foreach ($items as $item) { /** @var PHPClass $item */ $progress->advance(1, true); $output->write(" Creating <info>" . $output->getFormatter()->escape($item->getFullName()) . "</info>... "); $path = $pathGenerator->getPath($item); $fileGen = new FileGenerator(); $fileGen->setFilename($path); $classGen = new \Zend\Code\Generator\ClassGenerator(); $itemClass = $item->getNamespace() . '\\' . $item->getName(); if (class_exists($itemClass)) { $existingClass = Generator\ClassGenerator::fromReflection(new ClassReflection($itemClass)); $classGen = $existingClass; } if ($generator->generate($classGen, $item)) { $fileGen->setClass($classGen); $fileGen->write(); $output->writeln("done."); if (isset($item->type) && $item->type->getName() != "") { $classMap[$item->type->getName()] = '\\' . $classGen->getNamespaceName() . '\\' . $classGen->getName(); } } else { $output->write("skip."); } } $mappingClassReflection = new ClassReflection(ClassMap::class); $mappingClass = Generator\ClassGenerator::fromReflection($mappingClassReflection); $mappingClass->getProperty('classMap')->setDefaultValue($classMap); $fileGen = new FileGenerator(); $fileGen->setFilename($mappingClassReflection->getFileName()); $fileGen->setClass($mappingClass); $fileGen->write(); $progress->finish(); }
protected function convert(AbstractConverter $converter, array $schemas, array $targets, OutputInterface $output) { $this->setClientMethodDocblocks(); $generator = new ClassGenerator(); $pathGenerator = new Psr4PathGenerator($targets); $converter->addAliasMap('http://schemas.microsoft.com/exchange/services/2006/types', 'Or', function ($type) use($schemas) { return "OrElement"; }); $converter->addAliasMap('http://schemas.microsoft.com/exchange/services/2006/types', 'And', function ($type) use($schemas) { return "AndElement"; }); $converter->addAliasMap('http://schemas.microsoft.com/exchange/services/2006/types', 'EmailAddress', function ($type) use($schemas) { return "garethp\\ews\\API\\Type\\EmailAddressType"; }); $items = $converter->convert($schemas); $progress = new ProgressBar($output, count($items)); $progress->start(count($items)); $classMap = []; foreach ($items as $item) { /** @var PHPClass $item */ $progress->advance(1, true); $path = $pathGenerator->getPath($item); $fileGen = new FileGenerator(); $fileGen->setFilename($path); $classGen = new \Zend\Code\Generator\ClassGenerator(); $itemClass = $item->getNamespace() . '\\' . $item->getName(); if (class_exists($itemClass)) { $fileGen = FileGenerator::fromReflectedFileName($path); $fileGen->setFilename($path); $classGen = Generator\ClassGenerator::fromReflection(new ClassReflection($itemClass)); } if ($generator->generate($classGen, $item)) { $namespace = $classGen->getNamespaceName(); $fileGen->setClass($classGen); $fileGen->write(); if (isset($item->type) && $item->type->getName() != "" && $item->getNamespace() !== Enumeration::class) { $classMap[$item->type->getName()] = '\\' . $namespace . '\\' . $classGen->getName(); } } else { } } $mappingClassReflection = new ClassReflection(ClassMap::class); $mappingClass = Generator\ClassGenerator::fromReflection($mappingClassReflection); $mappingClass->getProperty('classMap')->setDefaultValue($classMap); $fileGen = new FileGenerator(); $fileGen->setFilename($mappingClassReflection->getFileName()); $fileGen->setClass($mappingClass); $fileGen->write(); $progress->finish(); }
protected function convert(AbstractConverter $converter, array $schemas, array $targets, OutputInterface $output) { $items = $converter->convert($schemas); $dumper = new Dumper(); $pathGenerator = new Psr4PathGenerator($targets); $progress = new ProgressBar($output, count($items)); $progress->start(); foreach ($items as $item) { $progress->advance(); $output->write(" Item <info>" . key($item) . "</info>... "); $source = $dumper->dump($item, 10000); $output->write("created source... "); $path = $pathGenerator->getPath($item); $bytes = file_put_contents($path, $source); $output->writeln("saved source <comment>{$bytes} bytes</comment>."); } }
public function __construct(NamingStrategy $namingStrategy) { parent::__construct($namingStrategy); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "dateTime", function (Type $type) { return 'GoetasWebservices\\Xsd\\XsdToPhp\\XMLSchema\\DateTime'; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "time", function (Type $type) { return 'GoetasWebservices\\Xsd\\XsdToPhp\\XMLSchema\\Time'; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "date", function (Type $type) { return "DateTime<'Y-m-d'>"; }); }
public function __construct(NamingStrategy $namingStrategy) { parent::__construct($namingStrategy); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "dateTime", function (Type $type) { return "DateTime"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "time", function (Type $type) { return "DateTime"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "date", function (Type $type) { return "DateTime"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "anySimpleType", function (Type $type) { return "mixed"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "anyType", function (Type $type) { return "mixed"; }); }