@@ -97,13 +97,12 @@ public function clearCache(): bool
97
97
* Check if theme with given name exists.
98
98
*
99
99
* @param string $name
100
- * @param string $vendor
101
100
*
102
101
* @return bool
103
102
*/
104
- public function has (string $ name = null )
103
+ public function has (string $ name = null , ? Collection $ themes = null )
105
104
{
106
- return !is_null ($ this ->findByName ($ name ));
105
+ return !is_null ($ this ->findByName ($ name, null , $ themes ));
107
106
}
108
107
109
108
/**
@@ -113,13 +112,13 @@ public function has(string $name = null)
113
112
*
114
113
* @return mixed
115
114
*/
116
- public function get (string $ name = null )
115
+ public function get (string $ name = null , ? Collection $ themes = null )
117
116
{
118
117
if (is_null ($ name )) {
119
118
return $ this ->themes ;
120
119
}
121
120
122
- return $ this ->findByName ($ name );
121
+ return $ this ->findByName ($ name, null , $ themes );
123
122
}
124
123
125
124
/**
@@ -259,7 +258,6 @@ public function image(string $asset, string $alt = '', string $class = '', array
259
258
/**
260
259
* Get the current theme path to a versioned Mix file.
261
260
*
262
- * @param string $path
263
261
* @param string $manifestDirectory
264
262
* @param mixed $asset
265
263
*
@@ -314,13 +312,15 @@ public function filterNonActive(): Collection
314
312
*
315
313
* @param string $name
316
314
*/
317
- protected function findByName (string $ name = null , string $ vendor = null )
315
+ protected function findByName (string $ name = null , string $ vendor = null , ? Collection $ themes = null )
318
316
{
319
317
if (is_null ($ name )) {
320
318
return null ;
321
319
}
322
320
323
- return $ this ->themes ->first (function ($ theme ) use ($ name , $ vendor ) {
321
+ $ themes = $ themes ?? $ this ->themes ;
322
+
323
+ return $ themes ? $ themes ->first (function ($ theme ) use ($ name , $ vendor ) {
324
324
// normalize module name
325
325
$ name = str_replace (['-theme ' , 'theme- ' ], '' , $ name );
326
326
// Check if $name contains vendor
@@ -335,7 +335,7 @@ protected function findByName(string $name = null, string $vendor = null)
335
335
}
336
336
337
337
return $ theme ->getLowerName () === Str::lower ($ name ) && $ theme ->getLowerVendor () === Str::lower ($ vendor );
338
- });
338
+ }) : null ;
339
339
}
340
340
341
341
/**
@@ -349,15 +349,18 @@ protected function findThemes(): Collection
349
349
try {
350
350
$ themes = $ this ->scan (Config::get ('themes-manager.directory ' , 'themes ' ), Theme::class);
351
351
352
- $ themes ->each (function ($ theme ) {
352
+ $ themes ->each (function ($ theme ) use ( $ themes ) {
353
353
$ extendedThemeName = $ theme ->get ('extra.theme.parent ' );
354
354
if ($ extendedThemeName ) {
355
- if ($ this ->has ($ extendedThemeName )) {
356
- $ extendedTheme = $ this ->get ($ extendedThemeName );
355
+ if ($ this ->has ($ extendedThemeName, $ themes )) {
356
+ $ extendedTheme = $ this ->get ($ extendedThemeName, $ themes );
357
357
} else {
358
358
$ extendedTheme = new Theme ($ theme ->getPath ());
359
359
}
360
- $ theme ->setParent ($ extendedTheme );
360
+
361
+ if ($ extendedTheme ) {
362
+ $ theme ->setParent ($ extendedTheme );
363
+ }
361
364
}
362
365
});
363
366
} catch (ComposerLoaderException $ e ) {
0 commit comments