Example #1
0
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Bad require but needed :(
     require_once $this->getContainer()->getParameter('propel.path') . '/generator/lib/util/PropelSqlManager.php';
     $this->writeSection($output, '[Propel] You are running the command: propel:insert-sql');
     if ($input->getOption('force')) {
         if ($input->getOption('verbose')) {
             $this->additionalPhingArgs[] = 'verbose';
         }
         $connections = $this->getConnections();
         $sqlDir = $this->getApplication()->getKernel()->getRootDir() . DIRECTORY_SEPARATOR . 'propel' . DIRECTORY_SEPARATOR . 'sql';
         $manager = new \PropelSqlManager();
         $manager->setWorkingDirectory($sqlDir);
         $manager->setConnections($connections);
         if ($input->getOption('connection')) {
             list($name, $config) = $this->getConnection($input, $output);
             $this->doInsertSql($manager, $output, $name);
         } else {
             foreach ($connections as $name => $config) {
                 $output->writeln(sprintf('Use connection named <comment>%s</comment> in <comment>%s</comment> environment.', $name, $this->getApplication()->getKernel()->getEnvironment()));
                 $this->doInsertSql($manager, $output, $name);
             }
         }
     } else {
         $output->writeln('<error>You have to use --force to execute all SQL statements.</error>');
     }
 }
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Bad require but needed :(
     require_once $this->getContainer()->getParameter('propel.path') . '/generator/lib/util/PropelSqlManager.php';
     if ($input->getOption('force')) {
         $connections = $this->getConnections();
         $sqlDir = $this->getSqlDir();
         $manager = new \PropelSqlManager();
         $manager->setWorkingDirectory($sqlDir);
         $manager->setConnections($connections);
         if ($input->getOption('connection')) {
             list($name, $config) = $this->getConnection($input, $output);
             $this->doSqlInsert($manager, $output, $name);
         } else {
             foreach ($connections as $name => $config) {
                 $output->writeln(sprintf('Use connection named <comment>%s</comment> in <comment>%s</comment> environment.', $name, $this->getApplication()->getKernel()->getEnvironment()));
                 $this->doSqlInsert($manager, $output, $name);
             }
         }
     } else {
         $output->writeln('<error>You have to use --force to execute all SQL statements.</error>');
     }
 }