It looks like libraries_load_files() is still using drupal_add_js() and drupal_add_css() ... ~line 683: call_user_func('drupal_add_' . $type, $data, $options)
. Given that drupal_add_* functions appear to have recently been removed (change record) libraries_load() will no longer deal with js and css defined within a module's hook_libraries_info() implementation. Because of this calling libraries_load() will currently trigger an error (e.g., call_user_func() expects parameter 1 to be a valid callback....).
I'm not sure what this means for the module (or even how to categorize this issue), but it would be interesting if anyone can share thoughts on this. Perhaps an API function is needed to fetch a version of a $library array that can easily be merged directly into an '#attached' array on a render array?
Comment | File | Size | Author |
---|---|---|---|
#1 | 2183087-1.patch | 3.55 KB | tstoeckler |
Comments
Comment #1
tstoecklerThanks for reporting this!
We were also still using variable_get/set(), which was also removed.
Comitted attached patch to see if that unbreaks 8.x-3.x.
http://drupalcode.org/project/libraries.git/commit/632c2ea3681de4b415db6...
Comment #3
tstoecklerYay! https://qa.drupal.org/pifr/test/333418
Comment #5
tstoecklerComment #6
tstoecklerOr in fact let's leave this open to address the bigger issue that you mentioned in the OP.
Comment #7
tstoecklerSo really this is dependant upon decoupling the different library types. What we really want is to able to call libraries_attach_library($render_array, $library_name, $variant_name), similar to drupal_attach_tabledrag in in D8. That, however, makes no sense for PHP files, that has nothing to do with render arrays. Hmm....
Comment #8
rjacobs CreditAttribution: rjacobs commentedHaving a function like libraries_attach_library() was in-line with the solution that I had in mind. I'm actually (temporarily) using a local method to accomplish something similar to this in a 8.x module that I'm working on now ... see code here.
You mentioned that this has no relevance for php libraries, which would be true. I suppose it would only apply to libraries that declare 'js' and 'css' values in their 'files' definition. I'm wondering however if this would be a problem. An "attach" function like this could just go unused by code that loads a php-only library, and if it did use it, an unaltered array would come back. That said, I may still be missing some of the fundamental ways that Libraries API is changing for D8.
Comment #9
rjacobs CreditAttribution: rjacobs commentedI think I'll go ahead and close this as it seems like the more relevant conversations are now in:
#1386368: Register Libraries in hook_library()
#2418907: _drupal_add_js()/css() removed from core
#2090623: Turn hardcoded library_load_files() into a more modern, flexible system