Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Updating the make commands to use a custom views path #34060

Merged
merged 1 commit into from Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Illuminate/Console/GeneratorCommand.php
Expand Up @@ -366,6 +366,19 @@ protected function isReservedName($name)
return in_array($name, $this->reservedNames);
}

/**
* Get the views directory's path.
*
* @param string $path
* @return string
*/
protected function viewsDirectory($path = '')
{
$views = $this->laravel['config']['view.paths'][0] ?? resource_path('views');

return $views.($path ? DIRECTORY_SEPARATOR.$path : $path);
}

/**
* Get the console command arguments.
*
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Foundation/Console/ComponentMakeCommand.php
Expand Up @@ -53,9 +53,9 @@ public function handle()
*/
protected function writeView()
{
$view = $this->getView();

$path = resource_path('views').'/'.str_replace('.', '/', 'components.'.$view);
$path = $this->viewsDirectory(
str_replace('.', '/', 'components.'.$this->getView())
);

if (! $this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0777, true, true);
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Foundation/Console/MailMakeCommand.php
Expand Up @@ -51,7 +51,9 @@ public function handle()
*/
protected function writeMarkdownTemplate()
{
$path = resource_path('views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
$path = $this->viewsDirectory(
str_replace('.', '/', $this->option('markdown')).'.blade.php'
);

if (! $this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0755, true);
Expand Down
Expand Up @@ -51,7 +51,9 @@ public function handle()
*/
protected function writeMarkdownTemplate()
{
$path = resource_path('views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
$path = $this->viewsDirectory(
str_replace('.', '/', $this->option('markdown')).'.blade.php'
);

if (! $this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0755, true);
Expand Down