1 views_plugin_cache.inc | protected views_plugin_cache::assetDiff(array $assets, array $start_assets, $diff_function) |
Computes the differences between two JS/CSS asset arrays.
Parameters
array $assets: The current asset array.
array $start_assets: The original asset array.
string $diff_function: The function that should be used for computing the diff.
Return value
array: A CSS or JS asset array that contains all entries that are new/different in $assets.
File
- core/
modules/ views/ plugins/ views_plugin_cache.inc, line 235 - Definition of views_plugin_cache.
Class
- views_plugin_cache
- The base plugin to handle caching.
Code
protected function assetDiff(array $assets, array $start_assets, $diff_function) {
$diff = $diff_function($assets, $start_assets);
// Clean the resulting array up, since backdrop_array_diff_assoc_recursive()
// can leave half-populated arrays behind.
foreach ($diff as $key => $entry) {
// If only the weight was different, we can remove this entry.
if (count($entry) == 1 && isset($entry['weight'])) {
unset($diff[$key]);
}
// If there are other differences, we override with the latest entry.
elseif ($entry != $assets[$key]) {
$diff[$key] = $assets[$key];
}
}
return $diff;
}