-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #19 Fixed default config path guessing (HeahDude, javiereguiluz)
This PR was merged into the 1.0.x-dev branch. Discussion ---------- Fixed default config path guessing Closes #16. What do you think of doing it this way? Commits ------- bec7bbf Minor refactor 20226ab Fixed default config path guessing
- Loading branch information
Showing
4 changed files
with
38 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the EasyDeploy project. | ||
* | ||
* (c) Javier Eguiluz <javier.eguiluz@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace EasyCorp\Bundle\EasyDeployBundle\Helper; | ||
|
||
/** | ||
* @author Jules Pietri <jules@heahprod.com> | ||
*/ | ||
class SymfonyConfigPathGuesser | ||
{ | ||
private const LEGACY_CONFIG_DIR = '%s/app/config'; | ||
private const CONFIG_DIR = '%s/etc'; | ||
|
||
public static function guess(string $projectDir, string $stage): string | ||
{ | ||
if (is_dir($configDir = sprintf(self::CONFIG_DIR, $projectDir))) { | ||
return sprintf('%s/%s/deploy.php', $configDir, $stage); | ||
} | ||
|
||
if (is_dir($configDir = sprintf(self::LEGACY_CONFIG_DIR, $projectDir))) { | ||
return sprintf('%s/deploy_%s.php', $configDir, $stage); | ||
} | ||
|
||
throw new \RuntimeException(sprintf('None of the usual Symfony config dirs exist in the application. Create one of these dirs before continuing: "%s" or "%s".', self::CONFIG_DIR, self::LEGACY_CONFIG_DIR)); | ||
} | ||
} |