@@ -23,7 +23,7 @@ class ThemesManager
23
23
* @var string
24
24
*/
25
25
protected $ basePath ;
26
-
26
+
27
27
/**
28
28
* Scanned themes
29
29
* @var Collection
@@ -36,7 +36,7 @@ class ThemesManager
36
36
* @var \Illuminate\Contracts\Translation\Translator
37
37
*/
38
38
protected $ lang ;
39
-
39
+
40
40
/**
41
41
* View finder
42
42
* @var \Illuminate\View\Factory
@@ -47,21 +47,21 @@ class ThemesManager
47
47
* @var \Illuminate\Contracts\Filesystem\Filesystem
48
48
*/
49
49
private $ files ;
50
-
50
+
51
51
/**
52
52
* Engine compiler.
53
53
*
54
54
* @var array
55
55
*/
56
56
protected $ compilers = array ();
57
-
57
+
58
58
public function __construct (Factory $ view , Filesystem $ files , Translator $ lang )
59
59
{
60
60
$ this ->view = $ view ;
61
61
$ this ->files = $ files ;
62
62
$ this ->lang = $ lang ;
63
63
$ this ->basePath = config ('themes-manager.directory ' , 'themes ' );
64
-
64
+
65
65
// Scan available themes per group
66
66
try {
67
67
$ this ->themes = $ this ->scan ($ this ->basePath , Theme::class);
@@ -81,7 +81,7 @@ public function __construct(Factory $view, Filesystem $files, Translator $lang)
81
81
return $ this ;
82
82
}
83
83
}
84
-
84
+
85
85
/**
86
86
* Get all themes for group
87
87
*
@@ -122,7 +122,7 @@ public function get(string $name = null)
122
122
});
123
123
}
124
124
}
125
-
125
+
126
126
/**
127
127
* Set current active theme
128
128
*
@@ -132,19 +132,19 @@ public function get(string $name = null)
132
132
*
133
133
* @return ThemesManager
134
134
*/
135
- public function set (string $ name ) : ThemesManager
135
+ public function set (string $ name ): ThemesManager
136
136
{
137
137
if (!$ this ->has ($ name )) {
138
138
throw new ThemeNotFoundException ($ name );
139
139
}
140
-
140
+
141
141
optional ($ this ->current ())->disable ();
142
142
143
143
$ this ->enable ($ name );
144
-
144
+
145
145
return $ this ;
146
146
}
147
-
147
+
148
148
/**
149
149
* Get current theme for a group (current group if none provided).
150
150
*
@@ -167,7 +167,7 @@ public function current()
167
167
*
168
168
* @return $this
169
169
*/
170
- public function enable (string $ name , bool $ withEvent = true ) : ThemesManager
170
+ public function enable (string $ name , bool $ withEvent = true ): ThemesManager
171
171
{
172
172
if ($ theme = $ this ->get ($ name )) {
173
173
$ theme ->enable ($ withEvent );
@@ -206,21 +206,21 @@ public function enable(string $name, bool $withEvent = true) : ThemesManager
206
206
*
207
207
* @return ThemesManager
208
208
*/
209
- public function disable (string $ name , bool $ withEvent = true ) : ThemesManager
209
+ public function disable (string $ name , bool $ withEvent = true ): ThemesManager
210
210
{
211
211
if ($ theme = $ this ->get ($ name )) {
212
212
$ theme ->disable ($ withEvent );
213
213
}
214
214
215
215
return $ this ;
216
216
}
217
-
217
+
218
218
/**
219
219
* @param type $asset
220
220
*
221
221
* @return string
222
222
*/
223
- public function asset (string $ asset , $ absolutePath = false ) : string
223
+ public function asset (string $ asset , $ absolutePath = false ): string
224
224
{
225
225
return $ this ->url ($ asset , $ absolutePath );
226
226
}
@@ -231,7 +231,7 @@ public function asset(string $asset, $absolutePath = false) : string
231
231
* @param string $href
232
232
* @return string
233
233
*/
234
- public function style (string $ asset , $ absolutePath = false ) : string
234
+ public function style (string $ asset , $ absolutePath = false ): string
235
235
{
236
236
return sprintf (
237
237
'<link media="all" type="text/css" rel="stylesheet" href="%s"> ' ,
@@ -248,7 +248,7 @@ public function style(string $asset, $absolutePath = false) : string
248
248
* @param string $level
249
249
* @return string
250
250
*/
251
- public function script (string $ asset , string $ mode = '' , $ absolutePath = false , string $ type = 'text/javascript ' , string $ level = 'functionality ' ) : string
251
+ public function script (string $ asset , string $ mode = '' , $ absolutePath = false , string $ type = 'text/javascript ' , string $ level = 'functionality ' ): string
252
252
{
253
253
return sprintf (
254
254
'<script %s src="%s" data-type="%s" data-level="%s"></script> ' ,
@@ -268,7 +268,7 @@ public function script(string $asset, string $mode = '', $absolutePath = false,
268
268
* @param array $attributes
269
269
* @return string
270
270
*/
271
- public function image (string $ asset , string $ alt = '' , string $ class = '' , array $ attributes = [], $ absolutePath = false ) : string
271
+ public function image (string $ asset , string $ alt = '' , string $ class = '' , array $ attributes = [], $ absolutePath = false ): string
272
272
{
273
273
return sprintf (
274
274
'<img src="%s" alt="%s" class="%s" %s> ' ,
@@ -293,15 +293,15 @@ public function mix($asset, $manifestDirectory = '')
293
293
}
294
294
295
295
// Return url of current theme
296
- public function url (string $ asset , $ absolutePath = false ) : ?string
296
+ public function url (string $ asset , $ absolutePath = false ): ?string
297
297
{
298
298
// Split asset name to find concerned theme name
299
299
$ assetParts = explode (':: ' , $ asset );
300
300
if (count ($ assetParts ) == 2 ) {
301
301
$ name = $ assetParts [0 ];
302
302
$ asset = $ assetParts [1 ];
303
303
}
304
-
304
+
305
305
// If no Theme set, return /$asset
306
306
if (empty ($ name ) && !$ this ->current ()) {
307
307
return '/ ' . ltrim ($ asset , '/ ' );
@@ -329,7 +329,7 @@ private function htmlAttributes($attributes)
329
329
return $ key . '=" ' . $ attributes [$ key ] . '" ' ;
330
330
}, array_keys ($ attributes )));
331
331
}
332
-
332
+
333
333
/**
334
334
* @param Collection $themes
335
335
*
0 commit comments