/**
  *
  */
 public function save()
 {
     $fs = new Filesystem();
     $fs->dumpFile(Platform::sharedDir() . '/settings.local.php', $this->string);
     // Relink if missing.
     if (!$fs->exists(Platform::webDir() . '/sites/default/settings.local.php')) {
         $fs->symlink('../../../shared/settings.local.php', Platform::webDir() . '/sites/default/settings.local.php');
     }
 }
 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
  */
 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();
 }
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ShellHelper $shell */
     $shell = $this->getHelper('shell');
     $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
     $shell->setOutput($output);
     if (!is_dir(LocalProject::getProjectRoot() . '/docker/fg')) {
         $shell->execute(['git', 'clone', 'https://github.com/brendangregg/FlameGraph.git', LocalProject::getProjectRoot() . '/docker/fg']);
     }
     if (!is_dir(LocalProject::getProjectRoot() . '/docker/xhpfg')) {
         $shell->execute(['git', 'clone', 'https://github.com/msonnabaum/xhprof-flamegraphs.git', LocalProject::getProjectRoot() . '/docker/xhpfg']);
     }
     $this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>");
     $process = new Process('patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir());
     $process->mustRun(null);
 }
 /**
  * {@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';
 }
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->stdOut->writeln("<comment>Removing patch on Drupal for xhprof</comment>");
     $process = new Process('patch -p1 -R < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir());
     $process->mustRun(null);
 }