Skip to content

Commit 7e43459

Browse files
nshirotaylorotwell
andauthored
[11.x] Display view creation messages (#51925)
* [11.x] Display view creation messages * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 31cbd92 commit 7e43459

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/Illuminate/Foundation/Console/ComponentMakeCommand.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ class ComponentMakeCommand extends GeneratorCommand
4343
public function handle()
4444
{
4545
if ($this->option('view')) {
46-
$this->writeView(function () {
47-
$this->components->info($this->type.' created successfully.');
48-
});
49-
50-
return;
46+
return $this->writeView();
5147
}
5248

5349
if (parent::handle() === false && ! $this->option('force')) {
@@ -62,10 +58,9 @@ public function handle()
6258
/**
6359
* Write the view for the component.
6460
*
65-
* @param callable|null $onSuccess
6661
* @return void
6762
*/
68-
protected function writeView($onSuccess = null)
63+
protected function writeView()
6964
{
7065
$path = $this->viewPath(
7166
str_replace('.', '/', 'components.'.$this->getView()).'.blade.php'
@@ -88,9 +83,7 @@ protected function writeView($onSuccess = null)
8883
</div>'
8984
);
9085

91-
if ($onSuccess) {
92-
$onSuccess();
93-
}
86+
$this->components->info(sprintf('%s [%s] created successfully.', 'View', $path));
9487
}
9588

9689
/**

src/Illuminate/Foundation/Console/MailMakeCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ protected function writeMarkdownTemplate()
6969
$this->files->ensureDirectoryExists(dirname($path));
7070

7171
$this->files->put($path, file_get_contents(__DIR__.'/stubs/markdown.stub'));
72+
73+
$this->components->info(sprintf('%s [%s] created successfully.', 'Markdown view', $path));
7274
}
7375

7476
/**
@@ -91,6 +93,8 @@ protected function writeView()
9193
);
9294

9395
$this->files->put($path, $stub);
96+
97+
$this->components->info(sprintf('%s [%s] created successfully.', 'View', $path));
9498
}
9599

96100
/**

src/Illuminate/Foundation/Console/NotificationMakeCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ protected function writeMarkdownTemplate()
6565
}
6666

6767
$this->files->put($path, file_get_contents(__DIR__.'/stubs/markdown.stub'));
68+
69+
$this->components->info(sprintf('%s [%s] created successfully.', 'Markdown', $path));
6870
}
6971

7072
/**

src/Illuminate/Foundation/Console/ViewMakeCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ protected function handleTestCreation($path): bool
142142

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

145-
return File::put($this->getTestPath(), $contents);
145+
$result = File::put($path = $this->getTestPath(), $contents);
146+
147+
$this->components->info(sprintf('%s [%s] created successfully.', 'Test', $path));
148+
149+
return $result !== false;
146150
}
147151

148152
/**

0 commit comments

Comments
 (0)