From d1f1252ccbb8d1dc132e9596f30a2acb8994d35f Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Thu, 15 Feb 2018 21:51:28 +0100 Subject: [PATCH] Change the way the minify_exclude configurations can be used. --- app/code/Magento/Store/etc/config.xml | 4 ++-- .../Framework/View/Asset/Minification.php | 16 +++++++++++++++- .../View/Test/Unit/Asset/MinificationTest.php | 8 ++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Store/etc/config.xml b/app/code/Magento/Store/etc/config.xml index 470337a97dcd9..1011fe3051321 100644 --- a/app/code/Magento/Store/etc/config.xml +++ b/app/code/Magento/Store/etc/config.xml @@ -21,13 +21,13 @@ 0 0 - /tiny_mce/ + /tiny_mce/ 0 - /tiny_mce/ + /tiny_mce/ diff --git a/lib/internal/Magento/Framework/View/Asset/Minification.php b/lib/internal/Magento/Framework/View/Asset/Minification.php index 686f794d6318a..33c82a1810db6 100644 --- a/lib/internal/Magento/Framework/View/Asset/Minification.php +++ b/lib/internal/Magento/Framework/View/Asset/Minification.php @@ -143,7 +143,8 @@ 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); } @@ -151,4 +152,17 @@ public function getExcludes($contentType) } 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); + } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php index 2f6305f1cc73c..1cc2a3dd7e2b7 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php @@ -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'));