Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
What is the advised way of giving a path for getFile to find your plugin file if the plugin is in the /libraries folder outside of core? See: #2756597: Plugin path should not provide leading slash
Initially I gave it a path, and then there was a report about it not working correctly for installations in a subfolder. So I fixed that, and then the above issue pops up. What is the advised way to define a path to the plugin file that works in all scenarios?
Comments
Comment #2
kevinquillen CreditAttribution: kevinquillen at Velir commentedComment #3
darol100 CreditAttribution: darol100 as a volunteer and commentedComment #5
Wim LeersFirst: there is no such thing as an official
/libraries
folder next to the/core
folder. Of course it's fine to do that.Second: the documentation says this:
i.e. what is returned must be Drupal root-relative.
Third: looking at the first example I find in core, at
\Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalImage::getFile()
:If you run this, you get:
No matter if Drupal is installed in a subdirectory or not. That's why it's "Drupal root-relative".
So, both the before and after listed in #2729087: Path to plugin is incorrect unless base path is "/" are wrong. Because both have a leading slash, and that means it's not Drupal root-relative; it's relative to the actual root of the file system. What you need, is
libraries/a/b/c/file.js
.