Skip to content

Commit

Permalink
fix: error page for ignition less version
Browse files Browse the repository at this point in the history
  • Loading branch information
JeRabix committed Sep 8, 2024
1 parent df89636 commit a4d10f1
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
47 changes: 47 additions & 0 deletions src/Ignition/BeforeIgnitionRefactor/IconNotFoundSolution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace JeRabix\MoonshineIconify\Ignition\BeforeIgnitionRefactor;

use Illuminate\Support\Facades\Artisan;
use JeRabix\MoonshineIconify\Commands\DownloadIconifyIconsCommand;
use Spatie\Ignition\Contracts\RunnableSolution;


class IconNotFoundSolution implements RunnableSolution
{

public function getSolutionActionDescription(): string
{
return 'Download usage iconify icons';
}

public function getRunButtonText(): string
{
return 'Download usage iconify icons';
}

public function run(array $parameters = []): void
{
Artisan::call(DownloadIconifyIconsCommand::class);
}

public function getRunParameters(): array
{
return [];
}

public function getSolutionTitle(): string
{
return 'Icon not found';
}

public function getSolutionDescription(): string
{
return 'Icon not found';
}

public function getDocumentationLinks(): array
{
return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace JeRabix\MoonshineIconify\Ignition\BeforeIgnitionRefactor;

use Illuminate\Support\Arr;
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
use Spatie\LaravelIgnition\Exceptions\ViewException;
use Throwable;

class IconNotFoundSolutionProvider implements HasSolutionsForThrowable
{

public function canSolve(Throwable $throwable): bool
{
if (!$throwable instanceof ViewException) {
return false;
}

$viewPath = Arr::get($throwable->context(), 'view.view');

if (!$viewPath || $viewPath !== resource_path('views/vendor/moonshine/components/icon.blade.php')) {
return false;
}

return true;
}

public function getSolutions(Throwable $throwable): array
{
return [
new IconNotFoundSolution()
];
}
}
2 changes: 1 addition & 1 deletion src/Ignition/IconNotFoundSolutionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace JeRabix\MoonshineIconify\Ignition;

use Illuminate\Support\Arr;
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable;
use Spatie\LaravelIgnition\Exceptions\ViewException;
use Throwable;

Expand Down
7 changes: 4 additions & 3 deletions src/Providers/MoonshineIconifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Support\ServiceProvider;
use JeRabix\MoonshineIconify\Commands\DownloadIconifyIconsCommand;
use JeRabix\MoonshineIconify\Enums\WorkingMode;
use JeRabix\MoonshineIconify\Ignition\IconNotFoundSolutionProvider;

final class MoonshineIconifyServiceProvider extends ServiceProvider
{
Expand All @@ -30,9 +29,11 @@ public function boot(): void
if (version_compare($spatieIgnitionVersion, '2.8.0', '>=')) {
$rep = app(\Spatie\ErrorSolutions\SolutionProviderRepository::class);

$rep->registerSolutionProvider(IconNotFoundSolutionProvider::class);
$rep->registerSolutionProvider(\JeRabix\MoonshineIconify\Ignition\IconNotFoundSolutionProvider::class);
} else {
// TODO: Add support error page for spatie/laravel-ignition < 2.8.0
$rep = app(\Spatie\Ignition\Contracts\SolutionProviderRepository::class);

$rep->registerSolutionProvider(\JeRabix\MoonshineIconify\Ignition\BeforeIgnitionRefactor\IconNotFoundSolutionProvider::class);
}
}

Expand Down

0 comments on commit a4d10f1

Please sign in to comment.