File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
backend/app/Services/Infrastructure/HtmlPurifier Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 44
55use HTMLPurifier ;
66use HTMLPurifier_Config ;
7+ use Illuminate \Support \Facades \File ;
78
89class HtmlPurifierService
910{
10- public function __construct (
11- private readonly HTMLPurifier $ htmlPurifier
12- )
11+ private HTMLPurifier_Config $ config ;
12+
13+ public function __construct ( private readonly HTMLPurifier $ htmlPurifier )
1314 {
15+ $ this ->config = HTMLPurifier_Config::createDefault ();
16+
17+ $ cachePath = storage_path ('app/htmlpurifier ' );
18+ File::ensureDirectoryExists ($ cachePath , 0755 );
19+
20+ $ this ->config ->set ('Cache.SerializerPath ' , $ cachePath );
1421 }
1522
1623 public function purify (?string $ html ): string
@@ -19,9 +26,6 @@ public function purify(?string $html): string
1926 return '' ;
2027 }
2128
22- $ config = HTMLPurifier_Config::createDefault ();
23- $ config ->set ('Cache.SerializerPath ' , base_path ('storage/framework/cache ' ));
24-
25- return $ this ->htmlPurifier ->purify ($ html , $ config );
29+ return $ this ->htmlPurifier ->purify ($ html , $ this ->config );
2630 }
2731}
You can’t perform that action at this time.
0 commit comments