Issue #1882552 by andypost, phenaproxima, voleger, tedbow, alexpott, tim.plunkett, dawehner: Deprecate menu_list_system_menus() and menu_ui_get_menus()
parent
54781848a0
commit
7bc0a6d733
|
@ -12,8 +12,14 @@
|
|||
|
||||
/**
|
||||
* Returns an array containing the names of system-defined (default) menus.
|
||||
*
|
||||
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
|
||||
* \Drupal\system\Entity\Menu::loadMultiple() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3027453
|
||||
*/
|
||||
function menu_list_system_menus() {
|
||||
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453', E_USER_DEPRECATED);
|
||||
return [
|
||||
'tools' => 'Tools',
|
||||
'admin' => 'Administration',
|
||||
|
|
|
@ -20,6 +20,7 @@ use Drupal\menu_link_content\Entity\MenuLinkContent;
|
|||
use Drupal\node\NodeTypeInterface;
|
||||
use Drupal\system\Entity\Menu;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\system\MenuInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
|
@ -350,7 +351,10 @@ function menu_ui_form_node_form_submit($form, FormStateInterface $form_state) {
|
|||
function menu_ui_form_node_type_form_alter(&$form, FormStateInterface $form_state) {
|
||||
/** @var \Drupal\Core\Menu\MenuParentFormSelectorInterface $menu_parent_selector */
|
||||
$menu_parent_selector = \Drupal::service('menu.parent_form_selector');
|
||||
$menu_options = menu_ui_get_menus();
|
||||
$menu_options = array_map(function (MenuInterface $menu) {
|
||||
return $menu->label();
|
||||
}, Menu::loadMultiple());
|
||||
asort($menu_options);
|
||||
/** @var \Drupal\node\NodeTypeInterface $type */
|
||||
$type = $form_state->getFormObject()->getEntity();
|
||||
$form['menu'] = [
|
||||
|
@ -429,8 +433,14 @@ function menu_ui_form_node_type_form_builder($entity_type, NodeTypeInterface $ty
|
|||
* @return array
|
||||
* An array with the machine-readable names as the keys, and human-readable
|
||||
* titles as the values.
|
||||
*
|
||||
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
|
||||
* \Drupal\system\Entity\Menu::loadMultiple() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3027453
|
||||
*/
|
||||
function menu_ui_get_menus($all = TRUE) {
|
||||
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453', E_USER_DEPRECATED);
|
||||
if ($custom_menus = Menu::loadMultiple()) {
|
||||
if (!$all) {
|
||||
$custom_menus = array_diff_key($custom_menus, menu_list_system_menus());
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\KernelTests\Core\Menu;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Deprecation test cases for the menu layer.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
class MenuLegacyTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = ['menu_ui', 'system', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->installConfig('system');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecation of the menu_list_system_menus() function.
|
||||
*/
|
||||
public function testListSystemMenus(): void {
|
||||
$this->expectDeprecation('menu_list_system_menus() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453');
|
||||
$this->assertSame([
|
||||
'tools' => 'Tools',
|
||||
'admin' => 'Administration',
|
||||
'account' => 'User account menu',
|
||||
'main' => 'Main navigation',
|
||||
'footer' => 'Footer menu',
|
||||
], menu_list_system_menus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecation of the menu_ui_get_menus() function.
|
||||
*/
|
||||
public function testMenuUiGetMenus(): void {
|
||||
$this->expectDeprecation('menu_ui_get_menus() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453');
|
||||
$this->assertSame([
|
||||
'admin' => 'Administration',
|
||||
'footer' => 'Footer',
|
||||
'main' => 'Main navigation',
|
||||
'tools' => 'Tools',
|
||||
'account' => 'User account menu',
|
||||
], menu_ui_get_menus());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue