Skip to content

Commit

Permalink
#19 feat: create register config method to register all config file i…
Browse files Browse the repository at this point in the history
…n blog core
  • Loading branch information
tanhongit committed Jul 29, 2024
1 parent 6576488 commit 27f3348
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/Providers/BlogCoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class BlogCoreServiceProvider extends ServiceProvider
*/
public function boot(): void
{
$this->registerCommands();

$this->registerAssetLoading();

$this->registerAssetPublishing();
Expand All @@ -27,8 +25,9 @@ public function boot(): void
*/
public function register(): void
{
$configPath = __DIR__.'/../../config/blog-core.php';
$this->mergeConfigFrom($configPath, 'blog-core');
$this->registerConfigs();

$this->registerCommands();
}

/**
Expand Down Expand Up @@ -78,4 +77,21 @@ protected function registerAssetLoading(): void

$this->loadTranslationsFrom(__DIR__.'/../../lang', 'blog-core');
}

/**
* Register configs.
*
* @return void
*/
protected function registerConfigs(): void
{
$configDir = __DIR__.'/../../config';
$files = scandir($configDir);

foreach ($files as $file) {

Check failure on line 91 in src/Providers/BlogCoreServiceProvider.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.2

Argument of an invalid type array<int, string>|false supplied for foreach, only iterables are supported.

Check failure on line 91 in src/Providers/BlogCoreServiceProvider.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.3

Argument of an invalid type array<int, string>|false supplied for foreach, only iterables are supported.

Check failure on line 91 in src/Providers/BlogCoreServiceProvider.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.1

Argument of an invalid type array<int, string>|false supplied for foreach, only iterables are supported.

Check failure on line 91 in src/Providers/BlogCoreServiceProvider.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.2

Argument of an invalid type array<int, string>|false supplied for foreach, only iterables are supported.

Check failure on line 91 in src/Providers/BlogCoreServiceProvider.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.3

Argument of an invalid type array<int, string>|false supplied for foreach, only iterables are supported.
if (pathinfo($file, PATHINFO_EXTENSION) === 'php') {
$this->mergeConfigFrom($configDir . '/' . $file, pathinfo($file, PATHINFO_FILENAME));
}
}
}
}

0 comments on commit 27f3348

Please sign in to comment.