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.
Introduced in branch:
1.0.x
Introduced in version:
1.0.0
Impacts:
Module developers
Related Github Issues:
https://github.com/backdrop/backdrop-issues/issues/77