The D7 class registry has been replaced with a static class map, built through the hook system. This introduces hook_autoload_info()
.
Syntax Changes
Taking system.module as an example.
Before (in system.info file):
files[] = system.archiver.inc
files[] = system.mail.inc
files[] = system.queue.inc
files[] = system.tar.inc
files[] = system.updater.inc
After (in system.module file):
/**
* Implements hook_autoload_info().
*/
function system_autoload_info() {
return array(
'ArchiverTar' => 'system.archiver.inc',
'ArchiverZip' => 'system.archiver.inc',
'DefaultMailSystem' => 'system.mail.inc',
'TestingMailSystem' => 'system.mail.inc',
'DrupalQueue' => 'system.queue.inc',
'DrupalQueueInterface' => 'system.queue.inc',
'DrupalReliableQueueInterface' => 'system.queue.inc',
'SystemQueue' => 'system.queue.inc',
'MemoryQueue' => 'system.queue.inc',
'Archive_Tar' => 'system.tar.inc',
'ModuleUpdater' => 'system.updater.inc',
'ThemeUpdater' => 'system.updater.inc',
);
}
This change also requires no mixing of procedural and OO code in the same files. Previously we had a few random classes defined in places like node.module and entity.module. These classes have to be in their own files so that they don't trigger the autoloader just by extending a class.
The following functions related to the old class registry have been removed from Backdrop:
registry_rebuild()
registry_update()
drupal_file_scan_write_cache()
drupal_autoload_trait()
_drupal_file_scan_cache()
_drupal_get_filename_perform_file_scan()
_drupal_get_filename_fallback_trigger_error()
_drupal_trigger_error_with_delayed_logging()
_registry_check_code()
Introduced in branch:
1.0.x
Introduced in version:
1.0.0
Impacts:
Module developers
Related Github Issues: