function pdb_vue_js_alter in Decoupled Blocks: Vue.js 8
Implements hook_js_alter().
File
- ./
pdb_vue.module, line 140 - Any procedural Vue PHP work lives here.
Code
function pdb_vue_js_alter(&$javascript, AttachedAssetsInterface $assets) {
// Search for the spa-init.js file and move its weight to the bottom. This is
// needed so that it renders all components that come before it.
$spa_init = preg_grep("/spa-init/", array_keys($javascript));
if ($spa_init) {
// Get the weight of the last javascript file.
end($javascript);
$last_key = key($javascript);
$last_weight = $javascript[$last_key]['weight'];
// Get the key "filename" of the init javascript file.
$filename = array_shift($spa_init);
$javascript[$filename]['weight'] = $last_weight + 0.25;
}
}