예제 #1
0
 protected function openProjectWithSublimeText(ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $projectConfigPath = sprintf('%s/sublimetext/%s.sublime-project', $this->configDir, $projectConfig->getProjectName());
     !$this->logger ?: $this->logger->debug(sprintf('Checks the existence of file %s', $projectConfigPath));
     if (!$this->getLocalFilesystem()->exists($projectConfigPath) || $this->rewritesConfigFile) {
         $configData = ['folders' => [['follow_symlinks' => false, 'name' => $projectConfig->getProjectName(), 'path' => realpath($projectConfig->getLocalGitRepositoryDir())], ['follow_symlinks' => false, 'name' => 'vendor', 'path' => realpath($projectConfig->getLocalVendorDir())]]];
         if ($projectConfig->getLocalAssetsDir()) {
             $configData['folders'][] = ['follow_symlinks' => false, 'name' => 'assets_project', 'path' => realpath($projectConfig->getLocalAssetsDir())];
         }
         foreach ($this->directoriesConfig as $configCommonDirectory) {
             $configData['folders'][] = $configCommonDirectory;
         }
         $content = json_encode($configData, JSON_PRETTY_PRINT);
         !$this->logger ?: $this->logger->debug(sprintf('Dumps project json config into a file "<info>%s</info>".', $projectConfigPath));
         $this->getLocalFilesystem()->dumpFile($projectConfigPath, $content);
     }
     if ('' !== exec('which subl')) {
         $commandLine = 'subl -n ' . $projectConfigPath . (defined('PHP_WINDOWS_VERSION_BUILD') ? '' : ' > `tty`');
         !$this->logger ?: $this->logger->debug(sprintf('Executes command line %s', $commandLine));
         system($commandLine);
     } else {
         $output->writeln('<error><info>subl</info> command not found</error>');
     }
 }