* @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:----f+td1465EwALf27u5y9+XMIesvLvh4sWq+fJZ8FlD9O3V+nHmeCAZ3llee6YjmRQPo+X5GvYbyWWFDDoBVcjLgGiSnhIlpHtNNA8o/UZNJHP0Sc5nAV0eG3lSvmj6fQOiY6mLCJ5raPSMfbhX+OX+AXlUd/H9Fsb2bMQWdQISU/2w8XHAu3Y0ReTCjVgmF5+1R0Y64AxL3fVbE7kHX63CXoGy+zazXyxuze/NaeSADSYFye43oG6ULmCKjAh7T3XQWxXf7O2XGTtl9CAJisT1aumqpVQx2SbgE0fw6njpm5rKNuDGcGl5WBpYO/5eM0stlM9vc4dFBf3kmzKcO6w+35M/SJwiN7h06gYglQEp6HdBOds3DoernFa5MFrXKEq4pTtUpDOmLqKHw50Zy4CB5O0mzNmsNfw+puW8S2/xE+bh0KT4fFXMbojkSUJ0A7NhpzvToDhaiV7vDTDZLuTtUvNymJ+SPiwbUKYFs7ZC0w4dPCCsYXGIYfVanUHcApPrvmjsv/kD9EtSBBTC3nkFxxXdmwv8Vvqc7wGhiw+g8WgXPWzb0MJQWPahtiuNUzPJNI/qIYkNZ0KG99tgrYtxpBcA2FQnl66/TzF4+B7vXOyWBX1Ccf8ES3D81rcPZXMPNh6Hg9vYTKEfHn9osA5YrT8xuQh09k7HHJfgdPMS1Q=----ATTACHMENT:----MTA2OTc4Mjk5MjU5MzI3OCA0ODA3MDM5MDY3MzA1NDE1IDg4MzM0Mzc4OTI1NjgyNzA=