Skip to content

Commit

Permalink
[11.x] Display view creation messages (#51925)
Browse files Browse the repository at this point in the history
* [11.x] Display view creation messages

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
nshiro and taylorotwell committed Jun 27, 2024
1 parent 31cbd92 commit 7e43459
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
13 changes: 3 additions & 10 deletions src/Illuminate/Foundation/Console/ComponentMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ class ComponentMakeCommand extends GeneratorCommand
public function handle()
{
if ($this->option('view')) {
$this->writeView(function () {
$this->components->info($this->type.' created successfully.');
});

return;
return $this->writeView();
}

if (parent::handle() === false && ! $this->option('force')) {
Expand All @@ -62,10 +58,9 @@ public function handle()
/**
* Write the view for the component.
*
* @param callable|null $onSuccess
* @return void
*/
protected function writeView($onSuccess = null)
protected function writeView()
{
$path = $this->viewPath(
str_replace('.', '/', 'components.'.$this->getView()).'.blade.php'
Expand All @@ -88,9 +83,7 @@ protected function writeView($onSuccess = null)
</div>'
);

if ($onSuccess) {
$onSuccess();
}
$this->components->info(sprintf('%s [%s] created successfully.', 'View', $path));
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Foundation/Console/MailMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ protected function writeMarkdownTemplate()
$this->files->ensureDirectoryExists(dirname($path));

$this->files->put($path, file_get_contents(__DIR__.'/stubs/markdown.stub'));

$this->components->info(sprintf('%s [%s] created successfully.', 'Markdown view', $path));
}

/**
Expand All @@ -91,6 +93,8 @@ protected function writeView()
);

$this->files->put($path, $stub);

$this->components->info(sprintf('%s [%s] created successfully.', 'View', $path));
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Foundation/Console/NotificationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ protected function writeMarkdownTemplate()
}

$this->files->put($path, file_get_contents(__DIR__.'/stubs/markdown.stub'));

$this->components->info(sprintf('%s [%s] created successfully.', 'Markdown', $path));
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Foundation/Console/ViewMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ protected function handleTestCreation($path): bool

File::ensureDirectoryExists(dirname($this->getTestPath()), 0755, true);

return File::put($this->getTestPath(), $contents);
$result = File::put($path = $this->getTestPath(), $contents);

$this->components->info(sprintf('%s [%s] created successfully.', 'Test', $path));

return $result !== false;
}

/**
Expand Down

0 comments on commit 7e43459

Please sign in to comment.