9
9
use Hexadog \ThemesManager \Traits \ComposerTrait ;
10
10
use Illuminate \Container \Container ;
11
11
use Illuminate \Filesystem \Filesystem ;
12
+ use Illuminate \Mail \Markdown ;
12
13
use Illuminate \Support \Facades \Config ;
13
14
use Illuminate \Support \Facades \File ;
14
15
use Illuminate \Support \Facades \Log ;
@@ -230,7 +231,7 @@ public function disable(bool $withEvent = true): Theme
230
231
/**
231
232
* Enable the current theme.
232
233
*/
233
- public function enable (bool $ withEvent = true ): Theme
234
+ public function enable (bool $ withEvent = true , $ defaultViewPaths = null , $ defaultMailViewPaths = null ): Theme
234
235
{
235
236
// Check if current is active and currently disabled
236
237
if ($ this ->isActive () && $ this ->disabled ()) {
@@ -239,7 +240,7 @@ public function enable(bool $withEvent = true): Theme
239
240
}
240
241
241
242
$ this ->setStatus (true );
242
- $ this ->registerViews ();
243
+ $ this ->registerViews ($ defaultViewPaths , $ defaultMailViewPaths );
243
244
244
245
if ($ withEvent ) {
245
246
event (new ThemeEnabled ($ this ->getName ()));
@@ -364,7 +365,7 @@ protected function createPublicAssetsStructure()
364
365
/**
365
366
* Register theme's views in ViewFinder.
366
367
*/
367
- protected function registerViews ()
368
+ protected function registerViews ($ defaultViewPaths , $ defaultMailViewPaths )
368
369
{
369
370
// Create symlink for public resources if not existing yet
370
371
$ assetsPath = $ this ->getPath ('public ' );
@@ -390,8 +391,8 @@ protected function registerViews()
390
391
}, $ paths );
391
392
392
393
// Update config view.paths to work with errors views
393
- if (is_array (Config:: get ( ' view.paths ' ) )) {
394
- Config::set ('view.paths ' , array_merge ($ paths , Config:: get ( ' view.paths ' ) ));
394
+ if (is_array ($ this -> defaultViewPaths )) {
395
+ Config::set ('view.paths ' , array_merge ($ paths , $ defaultViewPaths ));
395
396
} else {
396
397
Config::set ('view.paths ' , $ paths );
397
398
}
@@ -416,13 +417,15 @@ protected function registerViews()
416
417
// Update config mail.markdown.paths to work with mail views
417
418
$ mailViewsPath = $ this ->getPath ('resources/views/vendor/mail ' );
418
419
if (File::exists ($ vendorViewsPath ) && is_dir ($ mailViewsPath )) {
419
- if (is_array (Config:: get ( ' mail.markdown.paths ' ) )) {
420
+ if (is_array ($ defaultMailViewPaths )) {
420
421
Config::set ('mail.markdown.paths ' , array_merge ([
421
422
$ mailViewsPath ,
422
- ], Config:: get ( ' mail.markdown.paths ' ) ));
423
+ ], $ defaultMailViewPaths ));
423
424
} else {
424
- Config::set ('mail.markdown.paths ' , $ mailViewsPath );
425
+ Config::set ('mail.markdown.paths ' , [ $ mailViewsPath] );
425
426
}
427
+
428
+ app ()->make (Markdown::class)->loadComponentsFrom (Config::get ('mail.markdown.paths ' ));
426
429
}
427
430
}
428
431
}
0 commit comments