Unverified Commit 6385a8fd authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3261252 by andypost: Remove deprecated system.module functions

parent cbcdb8b2
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -81,16 +81,12 @@ class SystemController extends ControllerBase {
   * @param \Drupal\Core\Extension\ModuleExtensionList $module_extension_list
   *   The module extension list.
   */
  public function __construct(SystemManager $systemManager, ThemeAccessCheck $theme_access, FormBuilderInterface $form_builder, ThemeHandlerInterface $theme_handler, MenuLinkTreeInterface $menu_link_tree, ModuleExtensionList $module_extension_list = NULL) {
  public function __construct(SystemManager $systemManager, ThemeAccessCheck $theme_access, FormBuilderInterface $form_builder, ThemeHandlerInterface $theme_handler, MenuLinkTreeInterface $menu_link_tree, ModuleExtensionList $module_extension_list) {
    $this->systemManager = $systemManager;
    $this->themeAccess = $theme_access;
    $this->formBuilder = $form_builder;
    $this->themeHandler = $theme_handler;
    $this->menuLinkTree = $menu_link_tree;
    if ($module_extension_list === NULL) {
      @trigger_error('The extension.list.module service must be passed to ' . __NAMESPACE__ . '\SystemController::__construct. It was added in Drupal 8.9.0 and will be required before Drupal 10.0.0.', E_USER_DEPRECATED);
      $module_extension_list = \Drupal::service('extension.list.module');
    }
    $this->moduleExtensionList = $module_extension_list;
  }

+1 −5
Original line number Diff line number Diff line
@@ -80,15 +80,11 @@ public static function create(ContainerInterface $container) {
   * @param \Drupal\Core\Update\UpdateHookRegistry|null $versioning_update_registry
   *   Versioning update registry service.
   */
  public function __construct(ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, KeyValueStoreExpirableInterface $key_value_expirable, ModuleExtensionList $extension_list_module, UpdateHookRegistry $versioning_update_registry = NULL) {
  public function __construct(ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, KeyValueStoreExpirableInterface $key_value_expirable, ModuleExtensionList $extension_list_module, UpdateHookRegistry $versioning_update_registry) {
    $this->moduleExtensionList = $extension_list_module;
    $this->moduleHandler = $module_handler;
    $this->moduleInstaller = $module_installer;
    $this->keyValueExpirable = $key_value_expirable;
    if ($versioning_update_registry === NULL) {
      @trigger_error('The update.update_hook_registry service must be passed to ' . __NAMESPACE__ . '\ModulesUninstallForm::__construct(). It was added in drupal:9.3.0 and will be required before drupal:10.0.0.', E_USER_DEPRECATED);
      $versioning_update_registry = \Drupal::service('update.update_hook_registry');
    }
    $this->updateRegistry = $versioning_update_registry;
  }

+0 −13
Original line number Diff line number Diff line
@@ -890,19 +890,6 @@ function system_region_list($theme, $show = REGIONS_ALL) {
  return $list;
}

/**
 * Array sorting callback; sorts modules by their name.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal\Core\Extension\ExtensionList::sortByName() instead.
 *
 * @see https://www.drupal.org/node/3225999
 */
function system_sort_modules_by_info_name($a, $b) {
  @trigger_error('system_sort_modules_by_info_name() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Extension\ExtensionList::sortByName() instead. See https://www.drupal.org/node/3225999', E_USER_DEPRECATED);
  return strcasecmp($a->info['name'], $b->info['name']);
}

/**
 * Sorts themes by their names, with the default theme listed first.
 *
+0 −33
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\system\Kernel;

use Drupal\KernelTests\KernelTestBase;

/**
 * @group system
 * @group legacy
 */
class SystemDeprecationTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['system', 'user'];

  /**
   * @see system_sort_modules_by_info_name()
   */
  public function testSystemSortModulesByInfoName() {
    $module_info = \Drupal::service('extension.list.module')->getAllInstalledInfo();
    $to_sort = [
      'user' => (object) ['info' => $module_info['user']],
      'system' => (object) ['info' => $module_info['system']],
    ];

    $this->expectDeprecation('system_sort_modules_by_info_name() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Extension\ExtensionList::sortByName() instead. See https://www.drupal.org/node/3225999');
    uasort($to_sort, 'system_sort_modules_by_info_name');
    $this->assertSame(['system', 'user'], array_keys($to_sort));
  }

}