You are here

function system_register in Drupal 8

Registers an extension in runtime registries for execution.

Parameters

string $type: The extension type; e.g., 'module' or 'theme'.

string $name: The internal name of the extension; e.g., 'node'.

string $uri: The relative URI of the primary extension file; e.g., 'core/modules/node/node.module'.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. There is no replacement for this function. Use the following sequence of code to achieve the same functionality:

$path = \Drupal::service("extension.list.{$type}")
  ->getPath($name);
\Drupal::service('class_loader')
  ->addPsr4('Drupal\\' . $name . '\\', \Drupal::root() . '/' . $path . '/src');
1 call to system_register()
ClassLoaderTest::testSystemRegisterDeprecation in core/tests/Drupal/Tests/Core/ClassLoader/ClassLoaderTest.php
@expectedDeprecation system_register() is deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. There is no replacement for this function. To achieve the same functionality use this snippet: $path =…

File

core/includes/module.inc, line 81
API for loading and interacting with Drupal modules.

Code

function system_register($type, $name, $uri) {
  @trigger_error('system_register() is deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. There is no replacement for this function. To achieve the same functionality use this snippet: $path = \\Drupal::service("extension.list.$type")->getPath($name); ' . "\\Drupal::service('class_loader')->addPsr4('Drupal\\\\' . \$name . '\\\\', \\Drupal::root() . '/' . \$path . '/src'); See https://www.drupal.org/node/3035275.", E_USER_DEPRECATED);
  \Drupal::service('class_loader')
    ->addPsr4('Drupal\\' . $name . '\\', \Drupal::root() . '/' . dirname($uri) . '/src');
}