Skip to content
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

Add livewire component discovery solution. #319

Merged
merged 6 commits into from Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/IgnitionServiceProvider.php
Expand Up @@ -39,6 +39,7 @@
use Facade\Ignition\SolutionProviders\MissingAppKeySolutionProvider;
use Facade\Ignition\SolutionProviders\MissingColumnSolutionProvider;
use Facade\Ignition\SolutionProviders\MissingImportSolutionProvider;
use Facade\Ignition\SolutionProviders\MissingLivewireComponentSolutionProvider;
use Facade\Ignition\SolutionProviders\MissingMixManifestSolutionProvider;
use Facade\Ignition\SolutionProviders\MissingPackageSolutionProvider;
use Facade\Ignition\SolutionProviders\RunningLaravelDuskInProductionProvider;
Expand Down Expand Up @@ -373,6 +374,7 @@ protected function getDefaultSolutions(): array
UnknownValidationSolutionProvider::class,
UndefinedPropertySolutionProvider::class,
MissingMixManifestSolutionProvider::class,
MissingLivewireComponentSolutionProvider::class,
];
}

Expand Down
29 changes: 29 additions & 0 deletions src/SolutionProviders/MissingLivewireComponentSolutionProvider.php
@@ -0,0 +1,29 @@
<?php

namespace Facade\Ignition\SolutionProviders;

use Facade\Ignition\Solutions\LivewireDiscoverSolution;
use Facade\IgnitionContracts\HasSolutionsForThrowable;
use Illuminate\Database\QueryException;
use Livewire\Exceptions\ComponentNotFoundException;
use Throwable;

class MissingLivewireComponentSolutionProvider implements HasSolutionsForThrowable
{
public function canSolve(Throwable $throwable): bool
{
if (! class_exists(ComponentNotFoundException::class)) {
return false;
}
if (! $throwable instanceof \Livewire\Exceptions\ComponentNotFoundException) {
ArnaudLier marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
ArnaudLier marked this conversation as resolved.
Show resolved Hide resolved

return true;
}

public function getSolutions(Throwable $throwable): array
{
return [new LivewireDiscoverSolution('A livewire component was not found')];
}
}
53 changes: 53 additions & 0 deletions src/Solutions/LivewireDiscoverSolution.php
@@ -0,0 +1,53 @@
<?php

namespace Facade\Ignition\Solutions;

use Facade\IgnitionContracts\RunnableSolution;
use Livewire\LivewireComponentsFinder;

class LivewireDiscoverSolution implements RunnableSolution
{
private $customTitle;

public function __construct($customTitle = '')
{
$this->customTitle = $customTitle;
}

public function getSolutionTitle(): string
{
return $this->customTitle;
}

public function getSolutionDescription(): string
{
return 'You might have forgotten to discover your livewire components. You can discover your livewire components using `php artisan livewire:discover`.';
}

public function getDocumentationLinks(): array
{
return [
'Livewire: Artisan Commands' => 'https://laravel-livewire.com/docs/2.x/artisan-commands',
];
}

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

public function getSolutionActionDescription(): string
{
return 'Pressing the button below will try to discover your components.';
}

public function getRunButtonText(): string
{
return 'Run livewire components discover';
}

public function run(array $parameters = [])
{
app(LivewireComponentsFinder::class)->build();
}
}