/**
  * @inheritdoc
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     // Validate we can run.
     if ($this->platformConfig === null) {
         $output->writeln('<error>Must run command within a Platform.sh project</error>');
         exit(1);
     }
     $this->projectPath = LocalProject::getProjectRoot();
     $this->projectName = Platform::projectName();
     $this->stdOut = $output;
     $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $this->stdIn = $input;
     self::$interactive = $input->isInteractive();
 }
 /**
  * Builds the settings.local.php file.
  */
 public function __construct()
 {
     $this->projectName = Platform::projectName();
     $this->containerName = Docker::getContainerName('mariadb');
     $this->string = "<?php\n\n";
     $this->dbFromLocal();
     $this->dbFromDocker();
 }
 public function copyConfigs()
 {
     // Copy configs
     foreach ($this->configsToCopy() as $fileName) {
         $this->fs->copy($this->resourcesDir . '/conf/' . $fileName, $this->projectPath . '/docker/conf/' . $fileName);
     }
     // Quick fix to make nginx PHP_IDE_CONFIG dynamic for now.
     $nginxConfFile = $this->projectPath . '/docker/conf/nginx.conf';
     $nginxConf = file_get_contents($nginxConfFile);
     $nginxConf = str_replace('{{ platform }}', Platform::projectName() . '.platform', $nginxConf);
     file_put_contents($nginxConfFile, $nginxConf);
 }
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->stdOut->writeln("<info>Syncing Platform.sh environment database to local</info>");
     // @todo this isn't as robust as getCurrentEnvironment().
     $git = $this->getHelper('shell');
     $currentBranch = $git->execute(['git', 'symbolic-ref', '--short', 'HEAD'], Platform::repoDir());
     $remoteAlias = '@' . Platform::projectName() . '.' . $currentBranch;
     $localAlias = '@' . Platform::projectName() . '._local';
     // @todo squeeze this into the ShellHelper arguments somehow.
     exec("drush {$remoteAlias} sql-dump --gzip | gzip -cd | drush {$localAlias} sqlc");
     //        $this->stdOut->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
     //        $shell = new ShellHelper($this->stdOut);
     //        $shell->execute([
     //            "drush $remoteAlias sql-dump --gzip | gzip -cd | drush $localAlias sqlc"
     //        ], null, true, false);
 }
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $url = 'http://' . Platform::projectName() . '.platform:' . Docker::getContainerPort('nginx', '80');
     $this->openUrl($url);
 }
 /**
  * @param $type
  *
  * @return string
  */
 public static function getContainerName($type)
 {
     $projectName = str_replace(array('-', '.'), '', Platform::projectName());
     return $projectName . '_' . $type . '_1';
 }