示例#1
0
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('sql')) {
         $modelCommand = new BuildModelCommand();
         $modelCommand->setApplication($this->getApplication());
         $modelCommand->execute($input, $output);
     }
     if (!$input->getOption('classes')) {
         $sqlCommand = new BuildSQLCommand();
         $sqlCommand->setApplication($this->getApplication());
         $sqlCommand->execute($input, $output);
     }
     if ($input->getOption('insert-sql')) {
         $insertCommand = new InsertSqlCommand();
         $insertCommand->setApplication($this->getApplication());
         // By-pass the '--force' required option
         $this->addOption('force', '', InputOption::VALUE_NONE, '');
         $input->setOption('force', true);
         $insertCommand->execute($input, $output);
     }
 }
 /**
  * Load XML fixtures
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  */
 protected function loadXmlFixtures(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Loading XML Fixtures.</info>');
     $finder = new Finder();
     // Create a "datadb.map" file
     $datadbContent = '';
     $datas = $finder->name('*.xml')->in($this->absoluteFixturesPath);
     foreach ($datas as $data) {
         $output->writeln(sprintf('Loaded fixtures from <comment>%s</comment>.', $data));
         $datadbContent .= $data->getFilename() . '=default' . PHP_EOL;
     }
     $datadbFile = $this->absoluteFixturesPath . '/datadb.map';
     file_put_contents($datadbFile, $datadbContent);
     $dest = $this->getApplication()->getKernel()->getRootDir() . '/propel/sql/';
     $this->callPhing('datasql', array('propel.sql.dir' => $dest, 'propel.schema.dir' => $this->absoluteFixturesPath));
     // Insert SQL
     $insertCommand = new InsertSqlCommand();
     $insertCommand->setApplication($this->getApplication());
     // By-pass the '--force' required option for inserting SQL
     $this->addOption('force', '', InputOption::VALUE_NONE, '');
     $input->setOption('force', true);
     $insertCommand->execute($input, $output);
     $this->removeTemporaryFiles();
     $this->filesystem->remove($datadbFile);
 }