Problem/Motivation
As noted in the change record to #3446354: Create a simple class to allow discovering recipes in the file system:
By default, the [recipe] Finder searches the directory configured by Composer for
drupal-recipepackages and the core recipes directory.
With #3639289: Recipes should be able to load recipes shipped by modules, modules can also now provide recipes. There is a use case for these module-provided recipes to be included in recipe Finder results. An example of this use case in Project Browser is Browse recipes shipped by modules.
Steps to reproduce
- Install a module that provides recipes.
- Instantiate the recipe Finder.
- List the found recipes.
Result: the module-provided recipes are not listed.
Proposed resolution
Add an ::inModules() method to the recipe Finder.
By default, module directories are not scanned.
$finder = new Finder();
But module Extension objects can be passed to the ::inModules() method.
$finder->inModules($this->moduleList->get('canvas'));
Searching in every module:
$finder = new Finder()
->inModules(...$this->moduleList->getList());
API changes
The recipe Finder has a new ::inModules() method used to include module-provided recipes in discovery.
Release notes snippet
None needed since this will be released as part of #3446354: Create a simple class to allow discovering recipes in the file system, not scheduled to be released until 12.1.x, and that issue's release notes cover the case.
Issue fork drupal-3642612
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
phenaproximaI propose a compromise:
Finder::inModules(Extension ...$modules).This way, we don't search in every module, just the ones you pass. This also means we don't need the module list service to be involved, and the finder can stay "pure".
Searching in every module would look, then, like this:
That's pretty clean.
Comment #4
nedjoYep, that looks great. Consistent with the Finder's design principles, and nicely implemented. Updating the summary.
Linking a similar issue I recently added, #3642407: Add recipe type filtering to recipe Finder.
Comment #5
phenaproximaComment #6
phenaproximaComment #7
nedjoNice, I've reviewed the code changes and everything looks great. I've suggested additions to the change record for #3446354 that could use review. With that in place, I think this'll be RTBC.
Comment #8
phenaproximaCR updated, setting to RTBC per #7.
Comment #9
nedjoAdded a comment on the MR. We're also seeing some warnings/failures in the pipeline, which I haven't looked into.
Comment #10
phenaproximaI pushed back on that; I don't think
staticmakes sense on a final class. So for now, restoring RTBC unless you feel strongly about that type hint.Comment #11
nedjoThx, makes sense, and we can switch to
staticif/when it's no longer final.Comment #12
nedjoRemoving note on change record update as it's already been made.