Skip to content

Commit

Permalink
Merge pull request #1420 from dev-lnk/publish_fix
Browse files Browse the repository at this point in the history
fix: publish command fix
  • Loading branch information
lee-to authored Dec 24, 2024
2 parents 88f1af7 + 8caa485 commit 9824b08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/Laravel/src/Commands/MoonShineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ private static function addResourceOrPageTo(string $class, string $to, bool $isP
file_put_contents($to, $content);
}

protected function replaceInConfig(string $key, string $value): void
{
protected function replaceInConfig(
string $key,
string $value,
?string $classReplace = null
): void {
$replace = "'$key' => $value,";

$pattern = "/['\"]" . $key . "['\"]\s*=>\s*[^'\"]+?,/";
$pattern = ! \is_null($classReplace) ?
"/['\"]" . $key . "['\"]\s*=>\s*" . $classReplace . "::class,/"
: "/['\"]" . $key . "['\"]\s*=>\s*[^'\"]+?,/";

file_put_contents(
config_path('moonshine.php'),
Expand Down
6 changes: 4 additions & 2 deletions src/Laravel/src/Commands/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ private function publishSystemForm(string $className, string $configKey): void

$this->replaceInConfig(
$configKey,
moonshineConfig()->getNamespace('\Forms\\' . $className) . "::class"
moonshineConfig()->getNamespace('\Forms\\' . $className) . "::class",
$className
);
}

Expand Down Expand Up @@ -202,7 +203,8 @@ private function publishSystemPage(string $className, string $configKey): void

$this->replaceInConfig(
$configKey,
moonshineConfig()->getNamespace('\Pages\\' . $className) . "::class"
moonshineConfig()->getNamespace('\Pages\\' . $className) . "::class",
$className
);
}

Expand Down

0 comments on commit 9824b08

Please sign in to comment.