@@ -32,15 +32,20 @@ class UrlGeneratorDecorator implements UrlGeneratorInterface
32
32
private $ thumbnailUrlTemplate ;
33
33
34
34
/**
35
- * @var bool
35
+ * @var bool|null
36
36
*/
37
37
private $ processSVG ;
38
38
39
39
/**
40
- * @var bool
40
+ * @var bool|null
41
41
*/
42
42
private $ processOriginalImages ;
43
43
44
+ /**
45
+ * @var SystemConfigService
46
+ */
47
+ private $ systemConfigService ;
48
+
44
49
public function __construct (
45
50
UrlGeneratorInterface $ decoratedService ,
46
51
ThumbnailUrlTemplateInterface $ thumbnailUrlTemplate ,
@@ -55,8 +60,7 @@ public function __construct(
55
60
$ this ->baseUrl = $ this ->normalizeBaseUrl ($ baseUrl );
56
61
57
62
$ this ->thumbnailUrlTemplate = $ thumbnailUrlTemplate ;
58
- $ this ->processSVG = (bool )$ systemConfigService ->get ('FroshPlatformThumbnailProcessor.config.ProcessSVG ' );
59
- $ this ->processOriginalImages = (bool )$ systemConfigService ->get ('FroshPlatformThumbnailProcessor.config.ProcessOriginalImages ' );
63
+ $ this ->systemConfigService = $ systemConfigService ;
60
64
}
61
65
62
66
public function getAbsoluteMediaUrl (MediaEntity $ media ): string
@@ -65,11 +69,11 @@ public function getAbsoluteMediaUrl(MediaEntity $media): string
65
69
return $ this ->decoratedService ->getAbsoluteMediaUrl ($ media );
66
70
}
67
71
68
- if (!$ this ->processOriginalImages ) {
72
+ if (!$ this ->canProcessOriginalImages () ) {
69
73
return $ this ->decoratedService ->getAbsoluteMediaUrl ($ media );
70
74
}
71
75
72
- if (!$ this ->processSVG && $ media ->getFileExtension () === 'svg ' ) {
76
+ if (!$ this ->canProcessSVG () && $ media ->getFileExtension () === 'svg ' ) {
73
77
return $ this ->decoratedService ->getAbsoluteMediaUrl ($ media );
74
78
}
75
79
@@ -88,7 +92,7 @@ public function getRelativeMediaUrl(MediaEntity $media): string
88
92
89
93
public function getAbsoluteThumbnailUrl (MediaEntity $ media , MediaThumbnailEntity $ thumbnail ): string
90
94
{
91
- if (!$ this ->processSVG && $ media ->getFileExtension () === 'svg ' ) {
95
+ if (!$ this ->canProcessSVG () && $ media ->getFileExtension () === 'svg ' ) {
92
96
return $ this ->decoratedService ->getAbsoluteMediaUrl ($ media );
93
97
}
94
98
@@ -133,4 +137,24 @@ private function createFallbackUrl(): string
133
137
134
138
return '' ;
135
139
}
140
+
141
+ private function canProcessSVG (): bool
142
+ {
143
+ if ($ this ->processSVG !== null ) {
144
+ return $ this ->processSVG ;
145
+ }
146
+
147
+ $ this ->processSVG = (bool )$ this ->systemConfigService ->get ('FroshPlatformThumbnailProcessor.config.ProcessSVG ' );
148
+ return $ this ->processSVG ;
149
+ }
150
+
151
+ private function canProcessOriginalImages (): bool
152
+ {
153
+ if ($ this ->processOriginalImages !== null ) {
154
+ return $ this ->processOriginalImages ;
155
+ }
156
+
157
+ $ this ->processOriginalImages = (bool )$ this ->systemConfigService ->get ('FroshPlatformThumbnailProcessor.config.ProcessOriginalImages ' );
158
+ return $ this ->processOriginalImages ;
159
+ }
136
160
}
0 commit comments