retrofit
retrofit copied to clipboard
Allow discovering extensions with legacy `.info` file
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.
Also info_parser
will need to be decorated as this does the YAML parsing for discovered extensions.
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’
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
If we are going to scan .info files, I wonder if we can provide auto discovery for class files.
That would be the idea. If we can parse .info
then we can include files in files[]
automatically.