Skip to content

Commit c36c495

Browse files
authored
Merge pull request #3 from cleptric/plugin-setup
Load features config inside `FeatureFlagsPlugin::bootstrap`
2 parents b0774f2 + 3a19161 commit c36c495

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Thumbs.db
2626
#######################
2727
# PHPUnit
2828
.phpunit.cache
29+
.phpunit.result.cache
2930
tests.sqlite
3031
# vim
3132
*~

README.md

+6-14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ The recommended way to install composer packages is:
1919
composer require markstory/cakephp-feature-flags
2020
```
2121

22+
Next, load the plugin by running the following command:
23+
24+
```
25+
bin/cake plugin load FeatureFlags
26+
```
27+
2228
## Usage
2329

2430
First you need to decide if you want simple boolean feature flags, or more complex
@@ -39,13 +45,6 @@ return [
3945
];
4046
```
4147

42-
Next, in `config/bootstrap.php` add the following:
43-
44-
```php
45-
// Load the feature configuration during application startup.
46-
Configure::load('features');
47-
```
48-
4948
In your `Application::services()` method add the following:
5049

5150
```php
@@ -104,13 +103,6 @@ return [
104103
];
105104
```
106105

107-
Next, in `config/bootstrap.php` add the following:
108-
109-
```php
110-
// Load the feature configuration during application startup.
111-
Configure::load('features');
112-
```
113-
114106
In your `Application::services()` method add the following:
115107

116108
```php

src/FeatureFlagsPlugin.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55

66
use Cake\Console\CommandCollection;
77
use Cake\Core\BasePlugin;
8+
use Cake\Core\Configure;
9+
use Cake\Core\PluginApplicationInterface;
810

911
/**
1012
* Plugin for FeatureFlags
1113
*/
1214
class FeatureFlagsPlugin extends BasePlugin
1315
{
1416
/**
15-
* Add commands for the plugin.
16-
*
17-
* @param \Cake\Console\CommandCollection $commands The command collection to update.
18-
* @return \Cake\Console\CommandCollection
17+
* @inheritDoc
1918
*/
2019
public function console(CommandCollection $commands): CommandCollection
2120
{
@@ -26,4 +25,14 @@ public function console(CommandCollection $commands): CommandCollection
2625
2726
return $commands;
2827
}
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
public function bootstrap(PluginApplicationInterface $app): void
33+
{
34+
parent::bootstrap($app);
35+
36+
Configure::load('features');
37+
}
2938
}

0 commit comments

Comments
 (0)