convert() abstract public method

abstract public convert ( array $schemas )
$schemas array
Example #1
0
 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();
 }
Example #2
0
 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();
 }
Example #3
0
 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();
 }
Example #4
0
 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>.");
     }
 }