Commit 0dacf7d3 authored by catch's avatar catch

Issue #2612334 by NickWilde: Remove dead code in...

Issue #2612334 by NickWilde: Remove dead code in \Drupal\Core\Asset\[Css|Js]Collection[Grouper|Optimizer]
parent f1d08c20
...@@ -12,8 +12,8 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface { ...@@ -12,8 +12,8 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface {
* *
* Puts multiple items into the same group if they are groupable and if they * Puts multiple items into the same group if they are groupable and if they
* are for the same 'media' and 'browsers'. Items of the 'file' type are * are for the same 'media' and 'browsers'. Items of the 'file' type are
* groupable if their 'preprocess' flag is TRUE, items of the 'inline' type * groupable if their 'preprocess' flag is TRUE, and items of the 'external'
* are always groupable, and items of the 'external' type are never groupable. * type are never groupable.
* *
* Also ensures that the process of grouping items does not change their * Also ensures that the process of grouping items does not change their
* relative order. This requirement may result in multiple groups for the same * relative order. This requirement may result in multiple groups for the same
...@@ -55,11 +55,6 @@ public function group(array $css_assets) { ...@@ -55,11 +55,6 @@ public function group(array $css_assets) {
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['media'], $item['browsers']) : FALSE; $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['media'], $item['browsers']) : FALSE;
break; break;
case 'inline':
// Always group inline items.
$group_keys = array($item['type'], $item['media'], $item['browsers']);
break;
case 'external': case 'external':
// Do not group external items. // Do not group external items.
$group_keys = FALSE; $group_keys = FALSE;
......
...@@ -133,16 +133,6 @@ public function optimize(array $css_assets) { ...@@ -133,16 +133,6 @@ public function optimize(array $css_assets) {
} }
break; break;
case 'inline':
// We don't do any caching for inline CSS assets.
$data = '';
foreach ($css_group['items'] as $css_asset) {
$data .= $this->optimizer->optimize($css_asset);
}
unset($css_assets[$order]['data']['items']);
$css_assets[$order]['data'] = $data;
break;
case 'external': case 'external':
// We don't do any aggregation and hence also no caching for external // We don't do any aggregation and hence also no caching for external
// CSS assets. // CSS assets.
......
...@@ -20,20 +20,15 @@ class CssOptimizer implements AssetOptimizerInterface { ...@@ -20,20 +20,15 @@ class CssOptimizer implements AssetOptimizerInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function optimize(array $css_asset) { public function optimize(array $css_asset) {
if (!in_array($css_asset['type'], array('file', 'inline'))) { if ($css_asset['type'] != 'file') {
throw new \Exception('Only file or inline CSS assets can be optimized.'); throw new \Exception('Only file CSS assets can be optimized.');
} }
if ($css_asset['type'] === 'file' && !$css_asset['preprocess']) { if (!$css_asset['preprocess']) {
throw new \Exception('Only file CSS assets with preprocessing enabled can be optimized.'); throw new \Exception('Only file CSS assets with preprocessing enabled can be optimized.');
} }
if ($css_asset['type'] === 'file') {
return $this->processFile($css_asset); return $this->processFile($css_asset);
} }
else {
return $this->processCss($css_asset['data'], $css_asset['preprocess']);
}
}
/** /**
* Processes the contents of a CSS asset for cleanup. * Processes the contents of a CSS asset for cleanup.
......
...@@ -12,8 +12,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface { ...@@ -12,8 +12,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface {
* *
* Puts multiple items into the same group if they are groupable and if they * Puts multiple items into the same group if they are groupable and if they
* are for the same browsers. Items of the 'file' type are groupable if their * are for the same browsers. Items of the 'file' type are groupable if their
* 'preprocess' flag is TRUE. Items of the 'inline', 'settings', or 'external' * 'preprocess' flag is TRUE. Items of the 'external' type are not groupable.
* type are not groupable.
* *
* Also ensures that the process of grouping items does not change their * Also ensures that the process of grouping items does not change their
* relative order. This requirement may result in multiple groups for the same * relative order. This requirement may result in multiple groups for the same
...@@ -43,9 +42,7 @@ public function group(array $js_assets) { ...@@ -43,9 +42,7 @@ public function group(array $js_assets) {
break; break;
case 'external': case 'external':
case 'setting': // Do not group external items.
case 'inline':
// Do not group external, settings, and inline items.
$group_keys = FALSE; $group_keys = FALSE;
break; break;
} }
......
...@@ -138,10 +138,8 @@ public function optimize(array $js_assets) { ...@@ -138,10 +138,8 @@ public function optimize(array $js_assets) {
break; break;
case 'external': case 'external':
case 'setting': // We don't do any aggregation and hence also no caching for external
case 'inline': // JS assets.
// We don't do any aggregation and hence also no caching for external,
// setting or inline JS assets.
$uri = $js_group['items'][0]['data']; $uri = $js_group['items'][0]['data'];
$js_assets[$order]['data'] = $uri; $js_assets[$order]['data'] = $uri;
break; break;
......
...@@ -16,7 +16,7 @@ public function optimize(array $js_asset) { ...@@ -16,7 +16,7 @@ public function optimize(array $js_asset) {
if ($js_asset['type'] !== 'file') { if ($js_asset['type'] !== 'file') {
throw new \Exception('Only file JavaScript assets can be optimized.'); throw new \Exception('Only file JavaScript assets can be optimized.');
} }
if ($js_asset['type'] === 'file' && !$js_asset['preprocess']) { if (!$js_asset['preprocess']) {
throw new \Exception('Only file JavaScript assets with preprocessing enabled can be optimized.'); throw new \Exception('Only file JavaScript assets with preprocessing enabled can be optimized.');
} }
......
...@@ -276,7 +276,7 @@ function testTypeFilePreprocessingDisabled() { ...@@ -276,7 +276,7 @@ function testTypeFilePreprocessingDisabled() {
* Tests a CSS asset with 'type' => 'external'. * Tests a CSS asset with 'type' => 'external'.
*/ */
function testTypeExternal() { function testTypeExternal() {
$this->setExpectedException('Exception', 'Only file or inline CSS assets can be optimized.'); $this->setExpectedException('Exception', 'Only file CSS assets can be optimized.');
$css_asset = array( $css_asset = array(
'group' => -100, 'group' => -100,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment