Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow discovering extensions with legacy .info file #29

Open
mglaman opened this issue Jul 18, 2023 · 5 comments
Open

Allow discovering extensions with legacy .info file #29

mglaman opened this issue Jul 18, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@mglaman
Copy link
Collaborator

mglaman commented Jul 18, 2023

This would simplify using Retrofit.

The logic is within \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory:

    foreach ($iterator as $key => $fileinfo) {
      // All extension names in Drupal have to be valid PHP function names due
      // to the module hook architecture.
      if (!preg_match(static::PHP_FUNCTION_PATTERN, $fileinfo->getBasename('.info.yml'))) {
        continue;
      }

It is invoked by \Drupal\Core\Extension\ExtensionDiscovery::scan.

One problem is that ExtensionDiscovery is constructed directly in some cases. But for modules and themes it is constructed and invoked by the ExtensionList class via \Drupal\Core\Extension\ExtensionList::doScanExtensions.

We can decorate extension.list.module and extension.list.theme. The decoration will need to extend the service's class (ModuleExtensionList, ThemeExtensionList.) The method getExtensionDiscovery will need to be overridden to return a new ExtensionDiscovery child class which supports .info discovery.

Then the new class will need to extend \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory to also scan for .info and convert for new .info.yml format.

This could be a major performance issue as it scans the disk twice.

@mglaman mglaman added the enhancement New feature or request label Jul 18, 2023
@mglaman
Copy link
Collaborator Author

mglaman commented Jul 18, 2023

Also info_parser will need to be decorated as this does the YAML parsing for discovered extensions.

@ndf
Copy link

ndf commented Oct 3, 2023

What is your opinion if we would have Drush command(s) that converts legacy .info and generates the .info.yml files? Something like: ‘$ drush retrofit:init theme’

@mglaman
Copy link
Collaborator Author

mglaman commented Oct 3, 2023

Yes, Drush commands would be the solution here. So you could target an extension and it'd create the file for you.

I paused on this. I probably shouldn't have because it makes it much easier to try out if the command is available. I'll bump my focus on this

@darrenoh
Copy link
Contributor

If we are going to scan .info files, I wonder if we can provide auto discovery for class files.

@mglaman
Copy link
Collaborator Author

mglaman commented Nov 23, 2023

That would be the idea. If we can parse .info then we can include files in files[] automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants