/**
  * Run phing action for the specified module
  *
  * @param string $app_code
  * @param string $action
  *
  * @throws \Exception
  */
 protected function runPhing($app_code, $action)
 {
     $base_dir = Locator::getBuildXmlPath($this->io);
     $phing_runner = new PhingRunner($this->io, realpath($base_dir));
     $phing_runner->Run($app_code, $action);
     //$this->io->write('    <warning>===Please run this command===</warning>');
     //$this->io->write("    phing -Dapp={$app_code} $action");
 }
 public function onPostAutoloadDump(ScriptEvent $event)
 {
     if (empty($this->postprocess)) {
         return;
     }
     $io = $event->getIO();
     $io->write("All code has been downloaded, now running database installation and migrations");
     $io->write("Migrations to run:\n     " . join("     \n", array_map(function ($el) {
         return 'phing -Dapp=' . $el[1] . ' ' . $el[0];
     }, $this->postprocess)));
     $phing_runner = new PhingRunner($io, Locator::getBuildXmlPath($io));
     foreach ($this->postprocess as $el) {
         list($operation, $app_code) = $el;
         try {
             $phing_runner->Run($app_code, $operation);
         } catch (\Exception $e) {
             if ($operation === 'install') {
                 $io->writeError("\n\n<warning>Got exception while running phing task. " . get_class($e) . ': ' . $e->getMessage() . " </warning>");
                 $io->writeError("<info>Trying to run upgrade instead</info>");
                 $phing_runner->Run($app_code, 'upgrade');
             } else {
                 $io->writeError("\n\n<error>Got exception while running phing task. " . get_class($e) . ': ' . $e->getMessage() . " </error>");
             }
         }
     }
 }