Skip to content

Commit

Permalink
Merge pull request #978 from hydephp/register-vendorized-configuratio…
Browse files Browse the repository at this point in the history
…n-files-in-bootstrapper-class

Register inlined configuration files in bootstrapper class
  • Loading branch information
caendesilva authored Feb 12, 2023
2 parents cc58457 + aaea400 commit 3642688
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
26 changes: 26 additions & 0 deletions packages/framework/src/Foundation/Internal/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Hyde\Foundation\Internal;

use Illuminate\Contracts\Config\Repository as RepositoryContract;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\LoadConfiguration as BaseLoadConfiguration;

Expand All @@ -18,4 +19,29 @@ protected function getConfigurationFiles(Application $app): array
$files['app'] = $app->basePath().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'config.php';
});
}

/** Load the configuration items from all the files. */
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository): void
{
parent::loadConfigurationFiles($app, $repository);

$this->mergeConfigurationFiles($repository, ['view', 'cache', 'commands', 'torchlight']);
}

/** These files do commonly not need to be customized by the user, so to get them out of the way, we don't include them in the default project install. */
protected function mergeConfigurationFiles(RepositoryContract $repository, array $keys): void
{
foreach ($keys as $key) {
$this->mergeConfigurationFile($repository, $key);
}
}

/** We of course want the user to be able to customize the config files, if they're present, so we'll merge their changes here. */
protected function mergeConfigurationFile(RepositoryContract $repository, string $key): void
{
$repository->set($key, array_merge(
require __DIR__."/../../../config/$key.php",
$repository->get($key, [])
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Illuminate\Support\ServiceProvider;

/**
* @deprecated Simplified class can now be inlined in the HydeServiceProvider.
*/
class ConfigurationServiceProvider extends ServiceProvider
{
public function register(): void
Expand All @@ -14,12 +17,6 @@ public function register(): void
$this->mergeConfigFrom(__DIR__.'/../../../config/hyde.php', 'hyde');
$this->mergeConfigFrom(__DIR__.'/../../../config/docs.php', 'docs');
$this->mergeConfigFrom(__DIR__.'/../../../config/markdown.php', 'markdown');

// Illuminate/Vendor Configuration Files
$this->mergeConfigFrom(__DIR__.'/../../../config/view.php', 'view');
$this->mergeConfigFrom(__DIR__.'/../../../config/cache.php', 'cache');
$this->mergeConfigFrom(__DIR__.'/../../../config/commands.php', 'commands');
$this->mergeConfigFrom(__DIR__.'/../../../config/torchlight.php', 'torchlight');
}

public function boot(): void
Expand Down

0 comments on commit 3642688

Please sign in to comment.