/**
  * 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 __construct(IOInterface $io, $base_dir = null)
 {
     $this->io = $io;
     // this is added for compatibility with installer 1.0 when it's upgraded to 1.1
     if (is_null($base_dir)) {
         $base_dir = realpath(Locator::getBuildXmlPath($io));
     }
     if (!file_exists($base_dir . '/build.xml')) {
         $this->io->write("<error>{$base_dir}/build.xml doesn't exist there, failure imminent</error>");
     }
     $this->base_dir = $base_dir;
 }
 public static function Construct(IOInterface $io)
 {
     $repo = new ArrayRepository();
     try {
         $web_folder = Locator::getWebFolderPath();
         $version_file = $web_folder . '/intranet/setup/_init/version.txt';
         if (!file_exists($version_file)) {
             throw new \Exception("No version.txt for core found - assuming framework is not installed");
         }
         $version_data = file($version_file);
         $core_version = $version_data[1];
         $normalizer = new VersionParser();
         $core_version_normalized = $normalizer->normalize($core_version);
         $io->write("Detected core version {$core_version} ({$core_version_normalized})");
         $core_package = new Package(FrameworkInstallerV8::PACKAGE_NAME, $core_version_normalized, $core_version);
         $repo->addPackage($core_package);
     } catch (\Exception $e) {
         $io->write($e->getMessage());
         // if can't determine location of 'web' folder, not adding the core package therefore letting
         // composer install it
     }
     return $repo;
 }
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     $web = Locator::getWebFolderPath();
     return $web . 'intranet/' . $this->getApplicationCode($package) . '/';
 }
 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>");
             }
         }
     }
 }