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 249cc2f
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');
$this->mergeCommandLineArguments($repository, '--no-api', 'hyde.api_calls');
}

$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): void
{
if (in_array($argumentName, $this->getArgv(), true)) {
$repository->set($configKey, true);
}
}

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

0 comments on commit 249cc2f

Please sign in to comment.