Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register vendor configuration files in bootstrapper instead of in provider #978

Merged
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