Skip to content

Commit 238efac

Browse files
committed
add hook starter_kit/config/additional_files to allow plugins to inject config files
1 parent 6413aa6 commit 238efac

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

config/container.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
$builder = new ContainerBuilder();
66

7-
$builder = apply_filters('starter_kit/container_builder', $builder);
8-
97
$builder->addDefinitions(require __DIR__ . '/dependencies.php');
108

119
return $builder->build();

config/dependencies.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
use Laminas\ConfigAggregator\ConfigAggregator;
44
use Laminas\ConfigAggregator\PhpFileProvider;
55

6-
$aggregator = new ConfigAggregator([
6+
// Base providers (theme)
7+
$providers = [
78
new PhpFileProvider(__DIR__ . '/common/*.php'),
89
new PhpFileProvider(__DIR__ . '/' . wp_get_environment_type() . '/*.php'),
9-
]);
10+
];
11+
12+
// Allow plugins to inject config files
13+
$additionalFiles = apply_filters('starter_kit/config/additional_files', []);
14+
foreach ($additionalFiles as $file) {
15+
$providers[] = new PhpFileProvider($file);
16+
}
17+
18+
$aggregator = new ConfigAggregator($providers);
1019

1120
return $aggregator->getMergedConfig();

src/Base/Constants.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
defined('ABSPATH') || exit;
66

7+
use StarterKit\Exception\ConfigEntryNotFoundException;
78
use StarterKit\Helper\Config;
89

910
/**
@@ -16,7 +17,7 @@ class Constants
1617
/**
1718
* Defines main constants for the theme.
1819
*
19-
* @throws \StarterKit\Exception\ConfigEntryNotFoundException
20+
* @throws ConfigEntryNotFoundException
2021
*/
2122
public static function define(): void
2223
{

0 commit comments

Comments
 (0)