43 private $configCache = [];
52 $this->scopeConfig = $scopeConfig;
53 $this->appState = $appState;
54 $this->scope = $scope;
65 if (!isset($this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType])) {
68 (bool)$this->scopeConfig->isSetFlag(
69 sprintf(self::XML_PATH_MINIFICATION_ENABLED, $contentType),
85 $extension = pathinfo($filename, PATHINFO_EXTENSION);
104 $extension = pathinfo($filename, PATHINFO_EXTENSION);
121 return substr($filename, strrpos($filename,
'.') - 4, 5) ==
'.min.';
130 foreach ($this->
getExcludes(pathinfo($filename, PATHINFO_EXTENSION)) as $exclude) {
131 if (preg_match(
'/' . str_replace(
'/',
'\/', $exclude) .
'/', $filename)) {
144 if (!isset($this->configCache[self::XML_PATH_MINIFICATION_EXCLUDES][$contentType])) {
146 $key = sprintf(self::XML_PATH_MINIFICATION_EXCLUDES, $contentType);
147 $excludeValues = $this->getMinificationExcludeValues($key);
148 foreach ($excludeValues as $exclude) {
149 if (trim($exclude) !=
'') {
163 private function getMinificationExcludeValues($key)
165 $configValues = $this->scopeConfig->getValue($key, $this->scope) ?? [];
167 if (!is_array($configValues)) {
168 $configValuesFromString = [];
169 foreach (explode(
"\n", $configValues) as $exclude) {
170 if (trim($exclude) !=
'') {
171 $configValuesFromString[] = trim($exclude);
174 $configValues = $configValuesFromString;
176 return array_values($configValues);
__construct(ScopeConfigInterface $scopeConfig, State $appState, $scope='store')
getExcludes($contentType)
isMinifiedFilename($filename)
const XML_PATH_MINIFICATION_ENABLED
addMinifiedSign($filename)
removeMinifiedSign($filename)
const XML_PATH_MINIFICATION_EXCLUDES