Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/Command/Mod/ModCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ private function createMod(string $name, string $sampleName, string $useClass, s
// Escribir en Init.php
$use = 'use ' . $useClass . ';';
$newInitContent = InitEditor::addUse($use);
if ($newInitContent !== null) {
if ($newInitContent !== null){
InitEditor::setInitContent($newInitContent);
}
else{
return Command::FAILURE;
Comment on lines +91 to +92

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Continue when the import already exists

When Init.php already contains the needed core import but is missing this mod registration—for example after a previous run aborted after writing the use, or after a user added the import manually—this branch returns before calling addToInitFunction(), leaving the newly created Mod/*.php file unregistered. InitEditor::addUse() returns null for duplicate imports as well as failures, so the duplicate-import case should be skipped rather than treated as fatal.

Useful? React with 👍 / 👎.

}
$newInitContent = InitEditor::addToInitFunction($initCode);
if ($newInitContent !== null) {
InitEditor::setInitContent($newInitContent);
} else {
return Command::FAILURE;
}

return Command::SUCCESS;
Expand Down