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>."); } }
protected static function generateJMSFiles(array $schemas) { $yamlcreator = new YamlConverter(new ShortNamingStrategy()); $yamlcreator->addNamespace('http://www.opentravel.org/OTA/2003/05', self::$namespace); $yamlcreator->addAliasMapType('http://www.opentravel.org/OTA/2003/05', 'DateOrTimeOrDateTimeType', 'Goetas\\Xsd\\XsdToPhp\\Tests\\JmsSerializer\\OTA\\OTADateTime'); $yamlcreator->addAliasMapType('http://www.opentravel.org/OTA/2003/05', 'DateOrDateTimeType', 'Goetas\\Xsd\\XsdToPhp\\Tests\\JmsSerializer\\OTA\\OTADateTime'); $yamlcreator->addAliasMapType('http://www.opentravel.org/OTA/2003/05', 'TimeOrDateTimeType', 'Goetas\\Xsd\\XsdToPhp\\Tests\\JmsSerializer\\OTA\\OTADateTime'); $items = $yamlcreator->convert($schemas); $dumper = new Dumper(); $pathGenerator = new JmsPsr4PathGenerator(array(self::$namespace . "\\" => self::$jmsDir)); foreach ($items as $item) { $path = $pathGenerator->getPath($item); file_put_contents($path, $dumper->dump($item, 10000)); } $serializerBuiler = \JMS\Serializer\SerializerBuilder::create(); $serializerBuiler->configureHandlers(function (HandlerRegistryInterface $h) use($serializerBuiler) { $serializerBuiler->addDefaultHandlers(); $h->registerSubscribingHandler(new BaseTypesHandler()); $h->registerSubscribingHandler(new XmlSchemaDateHandler()); $h->registerSubscribingHandler(new OTASchemaDateHandler()); }); $serializerBuiler->addMetadataDir(self::$jmsDir, self::$namespace); self::$serializer = $serializerBuiler->build(); }
public function testWriter() { $generator = new Psr4PathGenerator(array('myns\\' => $this->tmpdir)); $path = $generator->getPath(array('myns\\Bar' => true)); $this->assertEquals($path, $this->tmpdir . "/Bar.yml"); }