-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1028 Add DotenvConfigurator, for .env.etc files (nicolas-gre…
…kas) This PR was merged into the 2.x branch. Discussion ---------- Add DotenvConfigurator, for .env.etc files Needed for symfony/recipes#1342 Commits ------- 43b9ebf Add DotenvConfigurator, for .env.etc files
- Loading branch information
Showing
4 changed files
with
353 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Flex\Configurator; | ||
|
||
use Symfony\Flex\Lock; | ||
use Symfony\Flex\Recipe; | ||
use Symfony\Flex\Update\RecipeUpdate; | ||
|
||
class DotenvConfigurator extends AbstractConfigurator | ||
{ | ||
public function configure(Recipe $recipe, $vars, Lock $lock, array $options = []) | ||
{ | ||
foreach ($vars as $suffix => $vars) { | ||
$configurator = new EnvConfigurator($this->composer, $this->io, $this->options, $suffix); | ||
$configurator->configure($recipe, $vars, $lock, $options); | ||
} | ||
} | ||
|
||
public function unconfigure(Recipe $recipe, $vars, Lock $lock) | ||
{ | ||
foreach ($vars as $suffix => $vars) { | ||
$configurator = new EnvConfigurator($this->composer, $this->io, $this->options, $suffix); | ||
$configurator->unconfigure($recipe, $vars, $lock); | ||
} | ||
} | ||
|
||
public function update(RecipeUpdate $recipeUpdate, array $originalConfig, array $newConfig): void | ||
{ | ||
foreach ($originalConfig as $suffix => $vars) { | ||
$configurator = new EnvConfigurator($this->composer, $this->io, $this->options, $suffix); | ||
$configurator->update($recipeUpdate, $vars, $newConfig[$suffix] ?? []); | ||
} | ||
|
||
foreach ($newConfig as $suffix => $vars) { | ||
if (!isset($originalConfig[$suffix])) { | ||
$configurator = new EnvConfigurator($this->composer, $this->io, $this->options, $suffix); | ||
$configurator->update($recipeUpdate, [], $vars); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.