File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ class Block
1818
1919 public $ html ;
2020
21+ public $ cacheBust = 0 ;
22+
2123 protected $ id ;
2224
2325 /**
@@ -36,6 +38,12 @@ public function __construct($id = null)
3638 {
3739 // Generate a unique UUID.
3840 $ this ->id = $ id ?? (string )Str::uuid ();
41+
42+ // An easy way to bust all caches.
43+ $ this ->cacheBust = config ('torchlight.bust ' , 0 );
44+
45+ // Set a default theme.
46+ $ this ->theme = config ('torchlight.theme ' );
3947 }
4048
4149 /**
@@ -55,7 +63,7 @@ public function hash()
5563 $ this ->language .
5664 $ this ->theme .
5765 $ this ->code .
58- config ( ' torchlight.bust ' , 1 )
66+ $ this -> cacheBust
5967 );
6068 }
6169
@@ -100,6 +108,17 @@ public function setCode($code)
100108 return $ this ;
101109 }
102110
111+ /**
112+ * @param $number
113+ * @return $this
114+ */
115+ public function setCacheBust ($ number )
116+ {
117+ $ this ->cacheBust = $ number ;
118+
119+ return $ this ;
120+ }
121+
103122 /**
104123 * @param $html
105124 * @return $this
@@ -120,8 +139,9 @@ public function toRequestParams()
120139 'id ' => $ this ->id (),
121140 'hash ' => $ this ->hash (),
122141 'language ' => $ this ->language ,
123- 'theme ' => $ this ->theme ?? config ( ' torchlight.theme ' ) ,
142+ 'theme ' => $ this ->theme ,
124143 'code ' => $ this ->code ,
144+ 'bust ' => $ this ->cacheBust
125145 ];
126146 }
127147
Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ protected function request(Collection $blocks)
4141 $ response = Http::timeout (10 )
4242 ->withToken (config ('torchlight.token ' ))
4343 ->post ('https://torchlight.dev/api/highlight ' , [
44- 'bust ' => config ('torchlight.bust ' , 1 ),
4544 'blocks ' => $ this ->blocksAsRequestParam ($ blocks )->values (),
4645 ])
4746 ->json ();
You can’t perform that action at this time.
0 commit comments