1212namespace EasyCorp \Bundle \EasyDeployBundle \Command ;
1313
1414use EasyCorp \Bundle \EasyDeployBundle \Context ;
15- use EasyCorp \Bundle \EasyDeployBundle \Exception \ SymfonyVersionException ;
15+ use EasyCorp \Bundle \EasyDeployBundle \Helper \ SymfonyConfigPathGuesser ;
1616use Symfony \Component \Console \Command \Command ;
1717use Symfony \Component \Console \Input \InputArgument ;
1818use Symfony \Component \Console \Input \InputInterface ;
2121use Symfony \Component \Console \Question \ConfirmationQuestion ;
2222use Symfony \Component \Filesystem \Filesystem ;
2323use Symfony \Component \HttpKernel \Config \FileLocator ;
24- use Symfony \Component \HttpKernel \Kernel ;
2524
2625class DeployCommand extends Command
2726{
@@ -62,7 +61,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
6261 return $ this ->configFilePath = $ customConfigPath ;
6362 }
6463
65- $ defaultConfigPath = $ this ->getDefaultConfigPath ( $ input ->getArgument ('stage ' ));
64+ $ defaultConfigPath = SymfonyConfigPathGuesser:: guess ( $ this ->projectDir , $ input ->getArgument ('stage ' ));
6665 if (is_readable ($ defaultConfigPath )) {
6766 return $ this ->configFilePath = $ defaultConfigPath ;
6867 }
@@ -80,22 +79,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
8079 $ deployer ->doDeploy ();
8180 }
8281
83- private function getDefaultConfigPath (string $ stageName ) : string
84- {
85- $ symfonyVersion = Kernel::MAJOR_VERSION ;
86- $ defaultConfigPaths = [
87- 2 => sprintf ('%s/app/config/deploy_%s.php ' , $ this ->projectDir , $ stageName ),
88- 3 => sprintf ('%s/app/config/deploy_%s.php ' , $ this ->projectDir , $ stageName ),
89- 4 => sprintf ('%s/etc/%s/deploy.php ' , $ this ->projectDir , $ stageName ),
90- ];
91-
92- if (!isset ($ defaultConfigPaths [$ symfonyVersion ])) {
93- throw new SymfonyVersionException ($ symfonyVersion );
94- }
95-
96- return $ defaultConfigPaths [$ symfonyVersion ];
97- }
98-
9982 private function createDefaultConfigFile (InputInterface $ input , OutputInterface $ output , string $ defaultConfigPath , string $ stageName ) : void
10083 {
10184 $ helper = $ this ->getHelper ('question ' );
0 commit comments