By claudiu.cristea on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.8.x
Introduced in version:
8.8.0
Issue links:
Description:
Procedural functions drupal_classloader_register() and system_register() are deprecated. Use the class_loader service to add new namespaces.
Before
drupal_classloader_register('some_module', 'modules/custom/some_module');
system_register('module', 'some_module', 'modules/some_module/some_module.info.yml');
After
// Instead of drupal_classloader_register.
\Drupal::service('class_loader')->classLoader->addPsr4('Drupal\\some_module\\', \Drupal::root() . '/modules/custom/some_module/src');
// Instead of system_register()
$path = \Drupal::service('extension.list.module')->getPath('some_module');
\Drupal::service('class_loader')->classLoader->addPsr4('Drupal\\some_module\\', \Drupal::root() . $path . '/src');
Impacts:
Module developers
Themers
Site templates, recipes and distribution developers