Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293292

Make DirectoryWithMetadataDiscovery generic and reusable

$
0
0

Problem/Motivation

Drupal\Core\Plugin\Discovery\DirectoryWithMetadataDiscovery is a nice feature added by SDC.

It allows discovering a single plugin within a specific directory. The definition is still a YAML, but anything in the discovery belong to the plugin and can be checked and loaded.

It could be useful for many projects.

However, there is some stuff related to SDC hardcoded, which is surprising for a code living in the Drupal\Core\Plugin namespace:

    // Detect "my_component.component.yml".
    $regex = '/^([a-z0-9_-])+\.component\.yml$/i';
 

Proposed resolution

Remove information related to SDC and inject it from "outside"

Drupal\Core\Plugin\Discovery\DirectoryWithMetadataDiscovery is only called by Drupal\Core\Plugin\Discovery\DirectoryWithMetadataPluginDiscovery which is only called by Drupal\Core\Theme\ComponentPluginManager.

So, the data will need to be passed through DirectoryWithMetadataPluginDiscovery.

User interface changes

No

API changes

I believe this change can be done without breaking anything.


Viewing all articles
Browse latest Browse all 293292

Trending Articles