Skip to content

Commit

Permalink
Properly merge in feature class changes from master
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 13, 2024
1 parent b6e5925 commit 6b1c11d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/framework/src/Facades/Features.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace Hyde\Facades;

use Hyde\Hyde;
use Illuminate\Support\Str;
use Hyde\Pages\MarkdownPost;
use Hyde\Pages\DocumentationPage;
use Hyde\Enums\Feature;
use Hyde\Support\Concerns\Serializable;
use Hyde\Support\Contracts\SerializableContract;
use Illuminate\Support\Arr;

use function collect;
use function is_array;
use function array_filter;
use function extension_loaded;
Expand Down Expand Up @@ -53,7 +55,7 @@ public static function has(Feature $feature): bool
*/
public static function enabled(): array
{
return Arr::map(Hyde::features()->features, fn (Feature $feature): string => $feature->value);
return Arr::map(Hyde::features()->features, fn (Feature $feature): string => Str::kebab($feature->name));
}

public static function hasHtmlPages(): bool
Expand Down Expand Up @@ -139,7 +141,7 @@ public static function hasTorchlight(): bool
public function toArray(): array
{
return Arr::mapWithKeys(Feature::cases(), fn (Feature $feature): array => [
$feature->value => static::has($feature),
Str::kebab($feature->name) => static::has($feature),
]);
}

Expand All @@ -152,9 +154,9 @@ public static function mock(string|array $feature, bool $enabled = null): void
{
foreach (is_array($feature) ? $feature : [$feature => $enabled] as $feature => $enabled) {
if ($enabled !== true) {
Hyde::features()->features = array_filter(Hyde::features()->features, fn (Feature $search): bool => $search !== Feature::from($feature));
Hyde::features()->features = array_filter(Hyde::features()->features, fn (Feature $search): bool => Str::kebab($search->name) !== $feature);
} else {
Hyde::features()->features[] = Feature::from($feature);
Hyde::features()->features[] = collect(Feature::cases())->firstOrFail(fn (Feature $search): bool => Str::kebab($search->name) === $feature);
}
}
}
Expand Down

0 comments on commit 6b1c11d

Please sign in to comment.