Skip to content

Commit

Permalink
Extract helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 12, 2023
1 parent e3c8441 commit 03ef853
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/framework/src/Foundation/Internal/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ private function loadRuntimeConfiguration(Application $app, RepositoryContract $
{
if ($app->runningInConsole()) {
if ($this->getArgv() !== null) {
// Check if the `--pretty-urls` CLI argument is set, and if so, set the config value accordingly.
if (in_array('--pretty-urls', $this->getArgv(), true)) {
$repository->set('hyde.pretty_urls', true);
}

// Check if the `--no-api` CLI argument is set, and if so, set the config value accordingly.
if (in_array('--no-api', $this->getArgv(), true)) {
$repository->set('hyde.api_calls', false);
}
$this->mergeCommandLineArguments($repository, '--pretty-urls', 'hyde.pretty_urls', true);
$this->mergeCommandLineArguments($repository, '--no-api', 'hyde.api_calls', false);
}

$this->mergeRealtimeCompilerEnvironment($repository, 'HYDE_SERVER_DASHBOARD', 'hyde.server.dashboard.enabled');
$this->mergeRealtimeCompilerEnvironment($repository, 'HYDE_PRETTY_URLS', 'hyde.pretty_urls');
}
}

private function mergeCommandLineArguments(RepositoryContract $repository, string $argumentName, string $configKey, bool $value): void
{
if (in_array($argumentName, $this->getArgv(), true)) {
$repository->set($configKey, $value);
}
}

private function mergeRealtimeCompilerEnvironment(RepositoryContract $repository, string $environmentKey, string $configKey): void
{
if ($this->getEnv($environmentKey) !== false) {
Expand Down

0 comments on commit 03ef853

Please sign in to comment.