Skip to content

Commit def6fd1

Browse files
authored
Improves events documentation (#8558)
1 parent 2b215aa commit def6fd1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pennant.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -661,13 +661,17 @@ php artisan pennant:purge new-api purchase-button
661661

662662
Pennant dispatches a variety of events that can be useful when tracking feature flags throughout your application.
663663

664-
### `Laravel\Pennant\Events\RetrievingKnownFeature`
664+
### `Laravel\Pennant\Events\FeatureRetrieved`
665665

666-
This event is dispatched the first time a known feature is retrieved during a request for a specific scope. This event can be useful to create and track metrics against the feature flags that are being used throughout your application.
666+
This event is dispatched whenever a feature is retrieved and can be useful for creating and tracking metrics against a feature flag's usage throughout your application.
667667

668-
### `Laravel\Pennant\Events\RetrievingUnknownFeature`
668+
### `Laravel\Pennant\Events\FeatureResolved`
669669

670-
This event is dispatched the first time an unknown feature is retrieved during a request for a specific scope. This event can be useful if you have intended to remove a feature flag, but may have accidentally left some stray references to it throughout your application.
670+
This event is dispatched the first time a feature's value is resolved for a specific scope from it's definition or feature class resolver.
671+
672+
### `Laravel\Pennant\Events\UnknownFeatureResolved`
673+
674+
This event is dispatched the first time an unknown feature is resolved for a specific scope. This event can be useful if you have intended to remove a feature flag, but may have accidentally left some stray references to it throughout your application.
671675

672676
For example, you may find it useful to listen for this event and `report` or throw an exception when it occurs:
673677

@@ -678,7 +682,7 @@ namespace App\Providers;
678682

679683
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
680684
use Illuminate\Support\Facades\Event;
681-
use Laravel\Pennant\Events\RetrievingUnknownFeature;
685+
use Laravel\Pennant\Events\UnknownFeatureResolved;
682686

683687
class EventServiceProvider extends ServiceProvider
684688
{
@@ -687,13 +691,13 @@ class EventServiceProvider extends ServiceProvider
687691
*/
688692
public function boot(): void
689693
{
690-
Event::listen(function (RetrievingUnknownFeature $event) {
691-
report("Resolving unknown feature [{$event->feature}].");
694+
Event::listen(function (UnknownFeatureResolved $event) {
695+
report("Unknown feature resolved [{$event->feature}].");
692696
});
693697
}
694698
}
695699
```
696700

697-
### `Laravel\Pennant\Events\DynamicallyDefiningFeature`
701+
### `Laravel\Pennant\Events\DynamicallyRegisteringFeatureClass`
698702

699703
This event is dispatched when a class based feature is being dynamically checked for the first time during a request.

0 commit comments

Comments
 (0)