Skip to content

Commit

Permalink
Change the way the minify_exclude configurations can be used.
Browse files Browse the repository at this point in the history
  • Loading branch information
hostep committed Feb 17, 2018
1 parent 83ada52 commit d1f1252
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Store/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<merge_files>0</merge_files>
<minify_files>0</minify_files>
<minify_exclude>
/tiny_mce/
<tiny_mce>/tiny_mce/</tiny_mce>
</minify_exclude>
</js>
<css>
<minify_files>0</minify_files>
<minify_exclude>
/tiny_mce/
<tiny_mce>/tiny_mce/</tiny_mce>
</minify_exclude>
</css>
<image>
Expand Down
16 changes: 15 additions & 1 deletion lib/internal/Magento/Framework/View/Asset/Minification.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,26 @@ public function getExcludes($contentType)
if (!isset($this->configCache[self::XML_PATH_MINIFICATION_EXCLUDES][$contentType])) {
$this->configCache[self::XML_PATH_MINIFICATION_EXCLUDES][$contentType] = [];
$key = sprintf(self::XML_PATH_MINIFICATION_EXCLUDES, $contentType);
foreach (explode("\n", $this->scopeConfig->getValue($key, $this->scope)) as $exclude) {
$excludeValues = $this->getMinificationExcludeValues($key);
foreach ($excludeValues as $exclude) {
if (trim($exclude) != '') {
$this->configCache[self::XML_PATH_MINIFICATION_EXCLUDES][$contentType][] = trim($exclude);
}
}
}
return $this->configCache[self::XML_PATH_MINIFICATION_EXCLUDES][$contentType];
}

/**
* Get minification exclude values from configuration
*
* @param string $key
* @return string[]
*/
private function getMinificationExcludeValues($key)
{
$configValues = $this->scopeConfig->getValue($key, $this->scope) ?? [];

return array_values($configValues);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ public function testGetExcludes()
->expects($this->once())
->method('getValue')
->with('dev/js/minify_exclude')
->willReturn(
" /tiny_mce/ \n" .
" /tiny_mce2/ "
);
->willReturn([
'tiny_mce' => '/tiny_mce/',
'some_other_unique_name' => '/tiny_mce2/'
]);

$expected = ['/tiny_mce/', '/tiny_mce2/'];
$this->assertEquals($expected, $this->minification->getExcludes('js'));
Expand Down

1 comment on commit d1f1252

@govereem
Copy link

@govereem govereem commented on d1f1252 Jun 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in app/code/Magento/Store/etc/config.xml
<tiny_mce>/tiny_mce/</tiny_mce>

Will resolve in an error Notice: Array to string conversion in

return (string)$this->_config->getValue(
when running bin/magento app:config:import in relation to default values set in the env.php

By adding <tiny_mce> magento will resolve it as array.

Please sign in to comment.