Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"require": {
"php": "^8.1",
"livewire/livewire": "^3.2.3",
"livewire/livewire": "^3.2.3|^4.0",
"spatie/laravel-package-tools": "^1.9"
},
"autoload": {
Expand Down
4 changes: 3 additions & 1 deletion src/LivewireModalServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public function configurePackage(Package $package): void

public function registeringPackage()
{
UpgradeCommand::addThirdPartyUpgradeStep(WireElementsModalUpgrade::class);
if (class_exists(\Livewire\Features\SupportConsoleCommands\Commands\UpgradeCommand::class)) {
\Livewire\Features\SupportConsoleCommands\Commands\UpgradeCommand::addThirdPartyUpgradeStep(WireElementsModalUpgrade::class);
}
}

public function bootingPackage(): void
Expand Down
13 changes: 11 additions & 2 deletions src/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function resetState(): void
public function openModal($component, $arguments = [], $modalAttributes = []): void
{
$requiredInterface = \LivewireUI\Modal\Contracts\ModalComponent::class;
$componentClass = app(ComponentRegistry::class)->getClass($component);
$componentClass = $this->resolveComponentClass($component);
$reflect = new ReflectionClass($componentClass);

if ($reflect->implementsInterface($requiredInterface) === false) {
Expand Down Expand Up @@ -82,7 +82,7 @@ protected function resolveParameter($attributes, $parameterName, $parameterClass

if(enum_exists($parameterClassName)){
$enum = $parameterClassName::tryFrom($parameterValue);

if($enum !== null){
return $enum;
}
Expand Down Expand Up @@ -111,6 +111,15 @@ public function destroyComponent($id): void
unset($this->components[$id]);
}

protected function resolveComponentClass(string $component): string
{
if (class_exists(\Livewire\Mechanisms\ComponentRegistry::class)) {
return app(\Livewire\Mechanisms\ComponentRegistry::class)->getClass($component);
}

return app('livewire.finder')->resolveClassComponentClassName($component);
}

public function getListeners(): array
{
return [
Expand Down
11 changes: 10 additions & 1 deletion tests/LivewireModalComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

class LivewireModalComponentTest extends TestCase
{
protected function getComponentName(string $class): string
{
if (class_exists(\Livewire\Mechanisms\ComponentRegistry::class)) {
return app(\Livewire\Mechanisms\ComponentRegistry::class)->getName($class);
}

return app('livewire.finder')->normalizeName($class);
}

public function testCloseModal(): void
{
Livewire::test(DemoModal::class)
Expand Down Expand Up @@ -50,7 +59,7 @@ public function testModalEventEmitting(): void
])
->assertDispatched('someEvent');

$name = app(ComponentRegistry::class)->getName(DemoModal::class);
$name = $this->getComponentName(DemoModal::class);

Livewire::test(DemoModal::class)
->call('closeModalWithEvents', [
Expand Down