Skip to content

Commit

Permalink
Update WireElementsModalUpgrade.php (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladrusu authored Nov 12, 2023
1 parent 6a1f730 commit 135b5d3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/WireElementsModalUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public function handle(UpgradeCommand $console, \Closure $next)
$this->interactiveReplacement(
console: $console,
title: '$this->dispatch now expects named arguments.',
before: '$this->dispatch(\'openModal\', \'component-name\', {user: 1})',
after: '$this->dispatch(\'openModal\', {component: \'component-name\', arguments: {user: 1}})',
before: '$this->dispatch(\'openModal\', \'component-name\', [\'user\' => 1])',
after: '$this->dispatch(\'openModal\', component: \'component-name\', arguments: [\'user\' => 1])',
pattern: '/\$this->(?:dispatch|emit)\(\'openModal\'(?:,\s?)([^,|\)]*)(?:,\s?)?((?:(?:.|\s)*?).*)\)/',
replacement: function($matches) {
$component = $matches[1];
$arguments = $matches[2];
if (empty($arguments)) {
return "\$this->dispatch('openModal', { component: $component })";
return "\$this->dispatch('openModal', component: $component)";
}
return "\$this->dispatch('openModal', { component: $component, arguments: $arguments })";
return "\$this->dispatch('openModal', component: $component, arguments: $arguments)";
},
directories: ['app', 'tests']
);
Expand Down Expand Up @@ -72,4 +72,4 @@ public function handle(UpgradeCommand $console, \Closure $next)

return $next($console);
}
}
}

0 comments on commit 135b5d3

Please sign in to comment.