-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.x] Allow excluding features from purge command #89
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Laravel\Pennant\Contracts; | ||
|
||
interface CanListStoredFeatures | ||
{ | ||
/** | ||
* Retrieve the names of all stored features. | ||
* | ||
* @return array<string> | ||
*/ | ||
public function stored(): array; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
use Illuminate\Support\Lottery; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Support\Traits\Macroable; | ||
use Laravel\Pennant\Contracts\Driver as DriverContract; | ||
use Laravel\Pennant\Contracts\CanListStoredFeatures; | ||
use Laravel\Pennant\Contracts\Driver; | ||
use Laravel\Pennant\Contracts\FeatureScopeable; | ||
use Laravel\Pennant\Events\AllFeaturesPurged; | ||
use Laravel\Pennant\Events\DynamicallyRegisteringFeatureClass; | ||
|
@@ -24,12 +25,13 @@ | |
use Laravel\Pennant\LazilyResolvedFeature; | ||
use Laravel\Pennant\PendingScopedFeatureInteraction; | ||
use ReflectionFunction; | ||
use RuntimeException; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* @mixin \Laravel\Pennant\PendingScopedFeatureInteraction | ||
*/ | ||
class Decorator implements DriverContract | ||
class Decorator implements CanListStoredFeatures, Driver | ||
Comment on lines
-32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the useless |
||
{ | ||
use Macroable { | ||
__call as macroCall; | ||
|
@@ -191,6 +193,20 @@ public function defined(): array | |
return $this->driver->defined(); | ||
} | ||
|
||
/** | ||
* Retrieve the names of all stored features. | ||
* | ||
* @return array<string> | ||
*/ | ||
public function stored(): array | ||
{ | ||
if (! $this->driver instanceof CanListStoredFeatures) { | ||
throw new RuntimeException("The [{$this->name}] driver does not support listing stored features."); | ||
} | ||
|
||
return $this->driver->stored(); | ||
} | ||
|
||
/** | ||
* Get multiple feature flag values. | ||
* | ||
|
@@ -391,7 +407,7 @@ public function purge($features = null): void | |
Collection::wrap($features) | ||
->map($this->resolveFeature(...)) | ||
->pipe(function ($features) { | ||
$this->driver->purge($features); | ||
$this->driver->purge($features->all()); | ||
Comment on lines
-394
to
+410
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These methods support collections, but are typed to expect arrays. Fixing this while I notice it. |
||
|
||
$this->cache->forget( | ||
$this->cache->whereInStrict('feature', $features)->keys()->all() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here. Now matches the interface's comment.