Open omarlopesino opened 3 years ago
Nice! Btw the PR title is somewhat misleading. Currently the paths are not "absolute", they are just wrong and broken :)
There is a problem that is happening after this change.
We can define a library in a module or theme to be used in a pattern. See here the example pattern_library_one and pattern_library_two.
When doing this, if we remove the leading slash $base_path
, there is a problem later in \Drupal\Core\Asset\LibraryDiscoveryParser::buildByExtension() in the section "// Determine the file asset URI.".
After removing the leading slash, we end up having $options['data'] = $path . '/' . $source;
. This is not correct, since $path is pointing to the path of ui_patterns
module (it shouldn't, because this is a library defined in a custom module or theme) and also the source was already complete, so we end up having a broken path.
I give here an example where we have now a regression:
https://github.com/openeuropa/oe_bootstrap_theme/blob/1.0.0-alpha3/templates/patterns/tooltip/tooltip.ui_patterns.yml#L57
For this case, $options['data']
will get the value modules/contrib/ui_patterns/themes/contrib/oe_bootstrap_theme/templates/patterns/tooltip/tooltip.js
which of course will result in an error after visiting patterns page:
Warning: file_get_contents(modules/contrib/ui_patterns/themes/custom/oe_bootstrap_theme/templates/patterns/tooltip/tooltip.js): failed to open stream: No such file or directory in Drupal\Core\Asset\JsOptimizer->optimize() (line 25 of core/lib/Drupal/Core/Asset/JsOptimizer.php).
Before, with the leading slash, this was working, buildByExtension
was processing correctly the path and source.
Since twig 2.14.5 this is not supported. More info: https://github.com/twigphp/Twig/blob/v2.14.5/CHANGELOG