15
15
use Hyperf \Collection \Arr ;
16
16
use Hyperf \Context \ApplicationContext ;
17
17
18
- use function Hyperf \Config \config ;
19
-
20
18
class Telescope
21
19
{
22
20
public const SYNC = 0 ;
@@ -54,11 +52,6 @@ class Telescope
54
52
*/
55
53
public static bool $ useDarkTheme = false ;
56
54
57
- /**
58
- * Indicates if Telescope should record entries.
59
- */
60
- public static bool $ shouldRecord = false ;
61
-
62
55
/**
63
56
* Indicates if Telescope migrations will be run.
64
57
*/
@@ -145,10 +138,8 @@ public static function getPath(): string
145
138
146
139
/**
147
140
* Add a callback that adds tags to the record.
148
- *
149
- * @return static
150
141
*/
151
- public static function tag (Closure $ callback )
142
+ public static function tag (Closure $ callback ): static
152
143
{
153
144
static ::$ tagUsing [] = $ callback ;
154
145
@@ -157,10 +148,8 @@ public static function tag(Closure $callback)
157
148
158
149
/**
159
150
* Set the callback that filters the entries that should be recorded.
160
- *
161
- * @return static
162
151
*/
163
- public static function filter (Closure $ callback )
152
+ public static function filter (Closure $ callback ): static
164
153
{
165
154
static ::$ filterUsing [] = $ callback ;
166
155
@@ -172,6 +161,18 @@ public static function getConfig(): TelescopeConfig
172
161
return ApplicationContext::getContainer ()->get (TelescopeConfig::class);
173
162
}
174
163
164
+ /**
165
+ * Get the default JavaScript variables for Telescope.
166
+ */
167
+ public static function scriptVariables (): array
168
+ {
169
+ return [
170
+ 'path ' => static ::getConfig ()->getPath (),
171
+ 'timezone ' => static ::getConfig ()->getTimezone (),
172
+ 'recording ' => static ::getConfig ()->isRecording (),
173
+ ];
174
+ }
175
+
175
176
/**
176
177
* Determine if the given entry should be recorded.
177
178
*/
@@ -199,7 +200,7 @@ protected static function record(string $type, IncomingEntry $entry): void
199
200
return $ tagCallback ($ entry );
200
201
}, static ::$ tagUsing )));
201
202
202
- match (config ( ' telescope.save_mode ' , 0 )) {
203
+ match (static :: getConfig ()-> getSaveMode ( )) {
203
204
self ::ASYNC => TelescopeContext::addEntry ($ entry ),
204
205
self ::SYNC => $ entry ->create (),
205
206
default => $ entry ->create (),
0 commit comments