*/ class DataSqlCommand extends PhingCommand { /** * @see Command */ protected function configure() { $this ->setDescription('Generates sql from data xml') ->setHelp(<<propel:data-sql generates sql from data xml. php app/console propel:data-sql EOT ) ->setName('propel:data-sql') ; } /** * @see Command * * @throws \InvalidArgumentException When the target directory does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { $rootDir = $this->getApplication()->getKernel()->getRootDir(); $schemaDir = $rootDir . '/propel/schema/'; $sqlDir = $rootDir . '/propel/sql/'; $xmlDumpDir = $rootDir . '/propel/dump/xml/'; $filesystem = new Filesystem(); if (!is_dir($xmlDumpDir)) { $filesystem->mkdir($xmlDumpDir); } $finder = new Finder(); foreach($finder->name('*_data.xml')->in($xmlDumpDir) as $data) { $filesystem->copy((string) $data, $schemaDir . $data->getFilename()); } $ret = $this->callPhing('datasql', array( 'propel.sql.dir' => $sqlDir, 'propel.schema.dir' => $schemaDir, )); if ($ret) { $finder = new Finder(); foreach($finder->name('*_data.xml')->in($schemaDir) as $data) { $filesystem->remove($data); } $this->writeSummary($output, 'propel-data-sql'); $output->writeln(sprintf('SQL from XML data dump file is in %s.', $sqlDir)); } else { $this->writeTaskError('datasql', false); } } }