* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class ParseCommand extends Command { /** @var \PSX\Schema\SchemaManager */ protected $schemaManager; /** * @param \PSX\Schema\SchemaManager $schemaManager */ public function __construct(SchemaManager $schemaManager) { parent::__construct(); $this->schemaManager = $schemaManager; } protected function configure() { $this ->setName('schema:parse') ->setDescription('Parses an arbitrary source and outputs the schema in a specific format') ->addArgument('source', InputArgument::REQUIRED, 'The schema source this is either a absolute class name or schema file') ->addArgument('target', InputArgument::OPTIONAL, 'Optional the target folder otherwise the CWD is used') ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'Optional the output format possible values are: ' . implode(', ', GeneratorFactory::getPossibleTypes())) ->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Optional a config value which gets passed to the generator'); } protected function execute(InputInterface $input, OutputInterface $output) { $source = $input->getArgument('source'); $target = $input->getArgument('target') ?: getcwd(); $schema = $this->schemaManager->getSchema($source); if (!is_dir($target)) { throw new \RuntimeException('Target is not a directory'); } $factory = new GeneratorFactory(); $generator = $factory->getGenerator($input->getOption('format'), $input->getOption('config')); $response = $generator->generate($schema); if ($generator instanceof FileAwareInterface && $response instanceof Chunks) { $count = 0; foreach ($response->getChunks() as $file => $code) { file_put_contents($target . '/' . $generator->getFileName($file), $generator->getFileContent($code)); $count++; } $output->writeln('Generated ' . $count . ' files at ' . $target); } else { $output->write((string) $response); } return 0; } } __halt_compiler();----SIGNATURE:----YnfvqyIKv0H2IN6/kMzQlEddmqc+OfHZh7qROf3EBGha/leEMOWBRnQ9n1IxiYdF3HXkdTDg5YHuCwjAW7UHWpl53gT5KPxjeJLh8BnaEj0pFUa4TvFLCgZC0YkoZIvL2NRSq5VOj8lovqCYc3az5kKkpOyKYt+vA8J6t0hHTHNInATMZslE8xVHhbtUHl5/fMd2LNkao+Mqtk7esUChwNuWttWke+eAYeoiliR4PxiIy4cnEck9xcrSqUEoYjd2Y75hyk1Ixh7QaceI8lg0zxKU+9yQrgbpexj04QlizlnOtIylu8sX7iJi1fjv6/wxVIbrmBU+N8ISvV5jtPw2mr9F5n2KEyixtfUh7AEUCaANo3m6BZFON2szmfCL5zdksLZqvBMfjkjJySLXjk/0dDLU3uLoy/l3+152ZZ3mlKNwAmfTEsbrWBfjtVkIKeDYyEElLzxFhanAINV9tUVZxWj2owk+Nyxu1aJyS2Pa8kBQLVnhzGH7uhk1B4qmRTGap96ISmeLAceR6kYKeCceKHMVWEqVF7Ww4N/S/3/nszClMTnvkcDbUkx5Nct4KO+c5hTz7yAjVeLK37tOfxUgiuilj8a7gOOLiuWWGBuU/8FjCqH87Ly0/NIJpgj8eGk0lIu30KUI2FSG7DKVq0Porko/Rx4QF8ssbH8JP8MeSbY=----ATTACHMENT:----ODgyMjQ1MDEyMTQyMjAwIDExNjU3Njg5Mzk2OTgzOCAyMDA3NTM1MzY3OTg0OTYz