-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add livewire component discovery solution. (#319)
* Create LivewireDiscoverSolution.php * Create MissingLivewireComponentSolutionProvider.php * Update IgnitionServiceProvider.php * Update MissingLivewireComponentSolutionProvider.php * Update LivewireDiscoverSolution.php * fixes
- Loading branch information
Arnaud Lier
authored
Oct 14, 2020
1 parent
97bfeb5
commit 614bc70
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/SolutionProviders/MissingLivewireComponentSolutionProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Facade\Ignition\SolutionProviders; | ||
|
||
use Facade\Ignition\Solutions\LivewireDiscoverSolution; | ||
use Facade\IgnitionContracts\HasSolutionsForThrowable; | ||
use Illuminate\Database\QueryException; | ||
use Livewire\Exceptions\ComponentNotFoundException; | ||
use Livewire\LivewireComponentsFinder; | ||
use Throwable; | ||
|
||
class MissingLivewireComponentSolutionProvider implements HasSolutionsForThrowable | ||
{ | ||
public function canSolve(Throwable $throwable): bool | ||
{ | ||
if (! class_exists(ComponentNotFoundException::class)) { | ||
return false; | ||
} | ||
if (! class_exists(LivewireComponentsFinder::class)) { | ||
return false; | ||
} | ||
if (! $throwable instanceof ComponentNotFoundException) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function getSolutions(Throwable $throwable): array | ||
{ | ||
return [new LivewireDiscoverSolution('A livewire component was not found')]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |