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-recipe packages 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

  1. Install a module that provides recipes.
  2. Instantiate the recipe Finder.
  3. 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

Command icon 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

nedjo created an issue. See original summary.

phenaproxima’s picture

I 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:

$finder->inModules(...$this->moduleList->getList())

That's pretty clean.

nedjo’s picture

Yep, 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.

phenaproxima’s picture

Issue summary: View changes
phenaproxima’s picture

Status: Active » Needs review
Issue tags: -Needs tests
nedjo’s picture

Issue summary: View changes

Nice, 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.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

CR updated, setting to RTBC per #7.

nedjo’s picture

Status: Reviewed & tested by the community » Needs work

Added a comment on the MR. We're also seeing some warnings/failures in the pipeline, which I haven't looked into.

phenaproxima’s picture

Status: Needs work » Reviewed & tested by the community

I pushed back on that; I don't think static makes sense on a final class. So for now, restoring RTBC unless you feel strongly about that type hint.

nedjo’s picture

Thx, makes sense, and we can switch to static if/when it's no longer final.

nedjo’s picture

Issue summary: View changes

Removing note on change record update as it's already been made.