Skip to content

Commit

Permalink
✨ Fix(src/FeatureFlagPluginServiceProvider.php): Conditionally discov…
Browse files Browse the repository at this point in the history
…er features based on the existence of the `app/Feature` directory.
  • Loading branch information
MarJose123 committed Jan 23, 2025
1 parent ae3e989 commit 2ac1ef4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/FeatureFlagPluginServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Laravel\Pennant\Feature;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Symfony\Component\Finder\Finder;

class FeatureFlagPluginServiceProvider extends PackageServiceProvider
{
Expand All @@ -18,6 +19,14 @@ public function configurePackage(Package $package): void

public function bootingPackage()
{
Feature::discover();
$finder = new Finder();
$finder->directories()->name('Feature')->in(app_path());
/**
* `Feature` folder are required by the `laravel-pennant` if using a `discovery` method
* Boot only the Feature::discovers() if the Feature folder in app folder of laravel is existing.
*/
if($finder->hasResults()) {
Feature::discover();
}
}
}

0 comments on commit 2ac1ef4

Please sign in to comment.