Skip to content

Commit c4d8705

Browse files
ENGCOM-6035: Static Content Deploy - Get rid of in_array(array_keys($array)) #24904
2 parents 1cdb6b4 + 85f07b2 commit c4d8705

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
namespace Magento\Framework\View\Asset\PreProcessor;
77

88
use Magento\Framework\ObjectManagerInterface;
9+
use Magento\Framework\View\Asset\ContentProcessorInterface;
910
use Magento\Framework\View\Asset\File\FallbackContext;
1011
use Magento\Framework\View\Asset\LockerProcessInterface;
11-
use Magento\Framework\View\Asset\ContentProcessorInterface;
1212
use Magento\Framework\View\Asset\PreProcessor\AlternativeSource\AssetBuilder;
1313

1414
/**
@@ -139,11 +139,13 @@ private function processContent($path, $content, $module, FallbackContext $conte
139139
->setTheme($context->getThemePath())
140140
->setLocale($context->getLocale())
141141
->setModule($module)
142-
->setPath(preg_replace(
143-
'#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION)) . '$#',
144-
'.' . $name,
145-
$path
146-
))->build();
142+
->setPath(
143+
preg_replace(
144+
'#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION)) . '$#',
145+
'.' . $name,
146+
$path
147+
)
148+
)->build();
147149

148150
$processor = $this->objectManager->get($alternative[self::PROCESSOR_CLASS]);
149151
if (!$processor instanceof ContentProcessorInterface) {
@@ -168,4 +170,15 @@ public function getAlternativesExtensionsNames()
168170
{
169171
return array_keys($this->alternatives);
170172
}
173+
174+
/**
175+
* Check if file extension supported
176+
*
177+
* @param string $ext
178+
* @return bool
179+
*/
180+
public function isExtensionSupported($ext)
181+
{
182+
return isset($this->alternatives[$ext]);
183+
}
171184
}

lib/internal/Magento/Framework/View/Asset/PreProcessor/FileNameResolver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
*/
66
namespace Magento\Framework\View\Asset\PreProcessor;
77

8+
/**
9+
* Class FileNameResolver
10+
*
11+
* @package Magento\Framework\View\Asset\PreProcessor
12+
*/
813
class FileNameResolver
914
{
1015
/**
@@ -38,7 +43,7 @@ public function resolve($fileName)
3843
$compiledFile = $fileName;
3944
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
4045
foreach ($this->alternativeSources as $name => $alternative) {
41-
if (in_array($extension, $alternative->getAlternativesExtensionsNames(), true)
46+
if ($alternative->isExtensionSupported($extension)
4247
&& strpos(basename($fileName), '_') !== 0
4348
) {
4449
$compiledFile = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1);

0 commit comments

Comments
 (0)