This is a follow-up to #2815189: Library dependency checking can fail for instal profile (and also related to #2090623: Turn hardcoded library_load_files() into a more modern, flexible system). It's not urgent, but I wanted to capture some notes on it before I forget.
We are currently implementing our own Extension Hander service along with a custom Extension wrapper, which introduces a couple new layers of abstraction. As far as I can see these classes are currently only used to fetch some data from *.info.yml files that declare library_dependencies. I suppose that having things setup this way makes perfect sense as it encapsulates an extension-specific calculation with the Extension object itself. However, it also looks like the best way to traverse the *.info.yml data is with a static call to system_get_info(), which is not extension-specific in scope. So we end-up building custom Extension wrappers that have to then use global functionality to do their job. I'm wonder if it might make sense to refactor a bit and centralize the *.info.yml lookup within the Library Manager service instead.
Of course this suggestion could easily be misguided, specifically if:
- There was an alternative to system_get_info() that fetches *.info.yml data, preferably something that could be injected into the Extension object itself (unit testable).
- There are plans to further develop the custom Extension Hander service and Extension wrapper to do more than fetch library_dependencies data.
If any of those are true, then don't hesitate to close this :)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 2816155-kill-extension-manager.patch | 9.97 KB | tstoeckler |
| #3 | 2816115-3.patch | 9.99 KB | rjacobs |
Comments
Comment #2
rjacobs commentedAdding relation to #2815189: Library dependency checking can fail for instal profile.
Note also that I don't mean to nit-pick existing architecture... this is mostly just a follow-up to make sure that I understand the design intentions of this part of the module.
Comment #3
rjacobs commentedHere's a go at the idea... for the testbots.
Comment #4
rjacobs commentedThis is also architecturally related to #2090623: Turn hardcoded library_load_files() into a more modern, flexible system.
Comment #5
tstoecklerYes, you are 100% correct.
system_get_info()is kind of a shitty tool, but is precisely the correct tool for this job. I completely agree with this issue.I always had in mind to provide something like a
library_suggestionsor something like that for "optional dependencies", but even that probably wouldn't justify this abstraction I guess.Some notes on the actual patch:
Any reason for this, I don't really understand.
+=won't work here because these are indexed arrays, not associative arrays.It's actually LibraryManager.
Since I had the patch applied locally anyway to take a look at it in context, took the liberty of quickly updating it for the above. Feel free to improve on that (i.e. bring back the assert() which I removed, because I don't understand it, but there of course might be a reason for it, that I am simply missing) and commit some form of this.
Comment #6
tstoecklerWent ahead and committed this. As always, we can improve on this if you disagree with #5 or have other idea.
Thanks again, this is really nice!
Comment #7
rjacobs commentedThanks! It looks like the commit didn't get attached to the issue correctly, but it is in there, so that's great.
I'm coming-back to this a bit later than I'd like so I suppose it might be a bit moot to get to your questions now :) ... but here's what I can say on #5:
+ assert('!empty($info)');The assertion was preserved from the (now removed) Drupal\libraries\Extension\Extension\getLibraryDependencies(). It was actually this assertion that tipped-me-off to #2815189: Library dependency checking can fail for instal profile as $info for profile-based extentions was coming up empty. Anyway, there is probably no harm in removing it now.
+ $library_ids += isset($info['library_dependencies']) ? $info['library_dependencies'] : [];Oh yes, you are right. I'm not sure how I missed that.
+ * \Drupal\libraries\ExternalLibrary requires system_get_info() which is inTrue true... especially now that this change is committed :)
Thanks!