From 18ee5e9ad637a2291ae631095282bb723a838f99 Mon Sep 17 00:00:00 2001 From: atehnix Date: Tue, 2 Apr 2019 03:12:48 +0300 Subject: [PATCH] Add markdown stub --- src/Console/MailMakeCommand.php | 22 ++++++++++++++++++++++ src/Console/NotificationMakeCommand.php | 22 ++++++++++++++++++++++ src/Console/StubsPublishCommand.php | 1 + 3 files changed, 45 insertions(+) diff --git a/src/Console/MailMakeCommand.php b/src/Console/MailMakeCommand.php index e668ea9..f81c0e9 100644 --- a/src/Console/MailMakeCommand.php +++ b/src/Console/MailMakeCommand.php @@ -42,4 +42,26 @@ protected function getDefaultNamespace($rootNamespace) { return $rootNamespace . $this->getModuleNamespace() . config('stubs.namespaces.mail'); } + + /** + * Write the Markdown template for the mailable. + * + * @return void + */ + protected function writeMarkdownTemplate() + { + $path = resource_path('views/' . str_replace('.', '/', $this->option('markdown'))) . '.blade.php'; + + if (!$this->files->isDirectory(dirname($path))) { + $this->files->makeDirectory(dirname($path), 0755, true); + } + + $stub = config('stubs.path') . '/markdown.stub'; + + if (file_exists($stub)) { + $this->files->put($path, file_get_contents($stub)); + } else { + parent::writeMarkdownTemplate(); + } + } } diff --git a/src/Console/NotificationMakeCommand.php b/src/Console/NotificationMakeCommand.php index 30b320f..a63b2ed 100644 --- a/src/Console/NotificationMakeCommand.php +++ b/src/Console/NotificationMakeCommand.php @@ -42,4 +42,26 @@ protected function getDefaultNamespace($rootNamespace) { return $rootNamespace . $this->getModuleNamespace() . config('stubs.namespaces.notification'); } + + /** + * Write the Markdown template for the mailable. + * + * @return void + */ + protected function writeMarkdownTemplate() + { + $path = resource_path('views/' . str_replace('.', '/', $this->option('markdown'))) . '.blade.php'; + + if (!$this->files->isDirectory(dirname($path))) { + $this->files->makeDirectory(dirname($path), 0755, true); + } + + $stub = config('stubs.path') . '/markdown.stub'; + + if (file_exists($stub)) { + $this->files->put($path, file_get_contents($stub)); + } else { + parent::writeMarkdownTemplate(); + } + } } diff --git a/src/Console/StubsPublishCommand.php b/src/Console/StubsPublishCommand.php index f458fea..db5d95a 100644 --- a/src/Console/StubsPublishCommand.php +++ b/src/Console/StubsPublishCommand.php @@ -67,6 +67,7 @@ class StubsPublishCommand extends Command 'Illuminate/Foundation/Console/stubs/mail.stub', 'Illuminate/Foundation/Console/stubs/markdown-mail.stub', 'Illuminate/Foundation/Console/stubs/markdown-notification.stub', + 'Illuminate/Foundation/Console/stubs/markdown.stub', 'Illuminate/Foundation/Console/stubs/model.stub', 'Illuminate/Foundation/Console/stubs/notification.stub', 'Illuminate/Foundation/Console/stubs/observer.stub',