Same name and namespace in other branches
- 5.0.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::optimizeFile()
- 8.x-3.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::optimizeFile()
- 8.x-4.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::optimizeFile()
Perform any in-place optimization & pass to event for further optimization.
Parameters
array $asset: Core single asset definition array.
array $data: An array of extra file information (hashes, modification time etc).
Return value
bool|string False if contents unchanged or the new file path if optimized.
Overrides AssetOptimizer::optimizeFile
File
-
src/
Asset/ JsOptimizer.php, line 124
Class
- JsOptimizer
- The JavaScript Optimizer.
Namespace
Drupal\advagg\AssetCode
protected function optimizeFile(array &$asset, array $data) {
$asset_event = new AssetOptimizationEvent($data['contents'], $asset, $data);
$this->eventDispatcher
->dispatch($asset_event, AssetOptimizationEvent::JS);
$contents = $asset_event->getContent();
$asset = $asset_event->getAsset();
// If file contents are unaltered return FALSE.
if ($contents === $data['contents'] && !$this->gZip) {
return FALSE;
}
return $this->writeFile($contents, $data['cid']);
}