Commit 26dbb6b1 authored by romainj's avatar romainj

Replace the deprecated entityManager() by entityTypeManager() service

parent 4779313e
......@@ -21,11 +21,10 @@ function admin_toolbar_tools_toolbar() {
),
),
'#attached' => array(
'library' => array(
'admin_toolbar_tools/toolbar.icon',
),
'library' => array('admin_toolbar_tools/toolbar.icon'),
),
);
return $items;
}
......@@ -38,6 +37,7 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match)
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar Tools module allows you to to add more fonctionalities to the toolbar like flush caches, runnig cron.') . '</p>';
return $output;
}
}
......@@ -47,32 +47,32 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match)
*/
function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
$links['admin_toolbar_tools.help'] = array(
'title' => 'Tools',
'title' => t('Tools'),
'route_name' => '<front>',
'parent' => 'system.admin',
'weight' => -100
);
// Add system links.
$links['system.admin_index'] = array(
'title' => 'Index',
'title' => t('Index'),
'route_name' => 'system.admin_index',
'parent' => 'admin_toolbar_tools.help',
'weight' => -100,
);
$links['system.run_cron'] = array(
'title' => 'Run cron',
'title' => t('Run CRON'),
'route_name' => 'admin_toolbar.run.cron',
'parent' => 'admin_toolbar_tools.help',
'weight' => -8
);
$links['system.db_update'] = array(
'title' => 'Run Updates',
'title' => t('Run updates'),
'route_name' => 'system.db_update',
'parent' => 'admin_toolbar_tools.help',
'weight' => -6
);
$links['system.modules_uninstall'] = array(
'title' => 'Uninstall',
'title' => t('Uninstall'),
'route_name' => 'system.modules_uninstall',
'parent' => 'system.modules_list',
);
......@@ -99,63 +99,52 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
"config_entity" => "taxonomy_vocabulary"
),
);
/* Add common links to entities if parent module exists.
* The common links for entities are :
* - Editing entity, Deleting entity,manage fields for entity
* manage form display for an entity, entity view display
* and others links relating to entity
*/
/** Add common links to entities if parent module exists.
* The common links for entities are :
* - Editing entity, Deleting entity,manage fields for entity
* manage form display for an entity, entity view display
* and others links relating to entity
*/
foreach ($content_entities as $module_name => $entities) {
if (\Drupal::moduleHandler()->moduleExists($module_name)) {
$config_entity = $entities['config_entity'];
$content_entity = $entities['content_entity'];
foreach (\Drupal::entityManager()
->getBundleInfo($content_entity) as $machine_name => $bundle) {
foreach (\Drupal::entityTypeManager()->getStorage($config_entity)->loadMultiple() as $machine_name => $bundle) {
$links["entity." . $config_entity . ".edit_form." . $machine_name] = array(
'title' => $bundle['label'],
'title' => $bundle->label(),
'route_name' => "entity." . $config_entity . ".edit_form",
'parent' => "entity." . $config_entity . ".collection",
'route_parameters' => array(
$config_entity => $machine_name,
),
'route_parameters' => array($config_entity => $machine_name),
);
$links["entity." . $config_entity . ".delete_form." . $machine_name] = array(
'title' => 'Delete',
'title' => t('Delete'),
'route_name' => "entity." . $config_entity . ".delete_form",
'parent' => "entity." . $config_entity . ".edit_form." . $machine_name,
'route_parameters' => array(
$config_entity => $machine_name,
),
'route_parameters' => array($config_entity => $machine_name),
);
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
$links["entity." . $content_entity . ".field_ui_fields" . $machine_name] = array(
'title' => 'Manage fields',
'title' => t('Manage fields'),
'route_name' => "entity." . $content_entity . ".field_ui_fields",
'parent' => "entity." . $config_entity . ".edit_form." . $machine_name,
'route_parameters' => array(
$config_entity => $machine_name,
),
'route_parameters' => array($config_entity => $machine_name),
);
$links["entity.entity_form_display." . $content_entity . ".default" . $machine_name] = array(
'title' => 'Manage form display',
'title' => t('Manage form display'),
'route_name' => "entity.entity_form_display." . $content_entity . ".default",
'parent' => "entity." . $config_entity . ".edit_form." . $machine_name,
'route_parameters' => array(
$config_entity => $machine_name,
),
'route_parameters' => array($config_entity => $machine_name),
);
$links["entity.entity_view_display." . $content_entity . ".default" . $machine_name] = array(
'title' => 'Manage display',
'title' => t('Manage display'),
'route_name' => "entity.entity_view_display." . $content_entity . ".default",
'parent' => "entity." . $config_entity . ".edit_form." . $machine_name,
'route_parameters' => array(
$config_entity => $machine_name,
),
'route_parameters' => array($config_entity => $machine_name),
);
}
if (\Drupal::moduleHandler()->moduleExists('devel')) {
$links["entity.$config_entity.devel_load." . $machine_name] = array(
'title' => 'Devel',
'title' => t('Devel'),
'route_name' => "entity." . $config_entity . ".devel_load",
'parent' => "entity." . $config_entity . ".edit_form." . $machine_name,
'route_parameters' => array(
......@@ -166,47 +155,47 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
}
}
}
// Add user links.
// Add user links.
$links['user.admin_create'] = array(
'title' => 'Add user',
'title' => t('Add user'),
'route_name' => 'user.admin_create',
'parent' => 'entity.user.collection',
);
$links['user.admin_permissions'] = array(
'title' => 'Permissions',
'title' => t('Permissions'),
'route_name' => 'user.admin_permissions',
'parent' => 'entity.user.collection',
);
$links['entity.user_role.collection'] = array(
'title' => 'Roles',
'title' => t('Roles'),
'route_name' => 'entity.user_role.collection',
'parent' => 'entity.user.collection',
);
$links['user.logoutt'] = array(
'title' => 'Logout',
'title' => t('Logout'),
'route_name' => 'user.logout',
'parent' => 'admin_toolbar_tools.help',
'weight' => 10,
);
$links['user.role_add'] = array(
'title' => 'Add role',
'title' => t('Add role'),
'route_name' => 'user.role_add',
'parent' => 'entity.user_role.collection',
'weight' => -5,
);
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
$links['entity.user.field_ui_fields_'] = array(
'title' => 'Manage fields',
'title' => t('Manage fields'),
'route_name' => 'entity.user.field_ui_fields',
'parent' => 'entity.user.admin_form',
);
$links['entity.entity_form_display.user.default_'] = array(
'title' => 'Manage form display',
'title' => t('Manage form display'),
'route_name' => 'entity.entity_form_display.user.default',
'parent' => 'entity.user.admin_form',
);
$links['entity.entity_view_display.user.default_'] = array(
'title' => 'Manage display',
'title' => t('Manage display'),
'route_name' => 'entity.entity_view_display.user.default',
'parent' => 'entity.user.admin_form',
);
......@@ -216,41 +205,33 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => $role->label(),
'route_name' => 'entity.user_role.edit_form',
'parent' => 'entity.user_role.collection',
'route_parameters' => array(
'user_role' => $role->id(),
),
'route_parameters' => array('user_role' => $role->id()),
);
$links['entity.user_role.edit_permissions_form.' . $role->id()] = array(
'title' => "Edit permissions",
'title' => t('Edit permissions'),
'route_name' => 'entity.user_role.edit_permissions_form',
'parent' => 'entity.user_role.edit_form.' . $role->id(),
'route_parameters' => array(
'user_role' => $role->id(),
),
'route_parameters' => array('user_role' => $role->id()),
);
$links['entity.user_role.delete_form.' . $role->id()] = array(
'title' => "Delete",
'title' => t('Delete'),
'route_name' => 'entity.user_role.delete_form',
'parent' => 'entity.user_role.edit_form.' . $role->id(),
'route_parameters' => array(
'user_role' => $role->id(),
),
'route_parameters' => array('user_role' => $role->id()),
);
if (\Drupal::moduleHandler()->moduleExists('devel')) {
$links['entity.user_role.devel_load.' . $role->id()] = array(
'title' => "Devel",
'title' => t('Devel'),
'route_name' => 'entity.user_role.devel_load',
'parent' => 'entity.user_role.edit_form.' . $role->id(),
'route_parameters' => array(
'user_role' => $role->id(),
),
'route_parameters' => array('user_role' => $role->id()),
);
}
}
if (\Drupal::moduleHandler()->moduleExists('node')) {
$links['node.add_page']['parent'] = 'system.admin_content';
$links['node.type_add'] = array(
'title' => 'Add content type',
'title' => t('Add content type'),
'route_name' => 'node.type_add',
'parent' => 'entity.node_type.collection',
'weight' => -5
......@@ -261,48 +242,41 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => $label,
'route_name' => 'node.add',
'parent' => 'node.add_page',
'route_parameters' => array(
'node_type' => $machine_name,
),
'route_parameters' => array('node_type' => $machine_name),
);
}
}
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
$links['field_ui.entity_form_mode_add'] = array(
'title' => 'Add new form mode',
'title' => t('Add new form mode'),
'route_name' => 'field_ui.entity_form_mode_add',
'parent' => 'entity.entity_form_mode.collection',
);
$links['field_ui.entity_view_mode_add'] = array(
'title' => 'Add new view mode',
'title' => t('Add new view mode'),
'route_name' => 'field_ui.entity_view_mode_add',
'parent' => 'entity.entity_view_mode.collection',
);
}
if (\Drupal::moduleHandler()->moduleExists('taxonomy')) {
$links['entity.taxonomy_vocabulary.add_form'] = array(
'title' => 'Add vocabulary',
'title' => t('Add vocabulary'),
'route_name' => 'entity.taxonomy_vocabulary.add_form',
'parent' => 'entity.taxonomy_vocabulary.collection',
'weight' => -5,
);
foreach (\Drupal::entityManager()
->getBundleInfo('taxonomy_term') as $machine_name => $bundle) {
foreach (\Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->loadMultiple() as $machine_name => $bundle) {
$links['entity.taxonomy_term.add_form.' . $machine_name] = array(
'title' => $bundle['label'],
'title' => $bundle->label(),
'route_name' => 'entity.taxonomy_term.add_form',
'parent' => 'entity.taxonomy_vocabulary.edit_form',
'route_parameters' => array(
'taxonomy_vocabulary' => $machine_name,
),
'route_parameters' => array('taxonomy_vocabulary' => $machine_name),
);
}
}
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
$links['entity.menu.add_form'] = array(
'title' => 'Add menu',
'title' => t('Add menu'),
'route_name' => 'entity.menu.add_form',
'parent' => 'entity.menu.collection',
'weight' => -50
......@@ -313,53 +287,45 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => $label,
'route_name' => 'entity.menu.edit_form',
'parent' => 'entity.menu.collection',
'route_parameters' => array(
'menu' => $machine_name,
),
'route_parameters' => array('menu' => $machine_name),
);
$links['entity.menu.delete_form.' . $machine_name] = array(
'title' => 'Delete',
'title' => t('Delete'),
'route_name' => 'entity.menu.delete_form',
'parent' => 'entity.menu.edit_form.' . $machine_name,
'route_parameters' => array(
'menu' => $machine_name,
),
'route_parameters' => array('menu' => $machine_name),
);
if (\Drupal::moduleHandler()->moduleExists('devel')) {
$links['entity.menu.devel_load.' . $machine_name] = array(
'title' => 'Devel',
'title' => t('Devel'),
'route_name' => 'entity.menu.devel_load',
'parent' => 'entity.menu.edit_form.' . $machine_name,
'route_parameters' => array(
'menu' => $machine_name,
),
'route_parameters' => array('menu' => $machine_name),
);
}
$links['entity.menu.add_link_form.' . $machine_name] = array(
'title' => 'Add link',
'title' => t('Add link'),
'route_name' => 'entity.menu.add_link_form',
'parent' => 'entity.menu.edit_form.' . $machine_name,
'route_parameters' => array(
'menu' => $machine_name,
),
'route_parameters' => array('menu' => $machine_name),
);
}
}
// If module block_content is enabled.
if (\Drupal::moduleHandler()->moduleExists('block_content')) {
$links['block_content.add_page'] = array(
'title' => 'Add custom block',
'title' => t('Add custom block'),
'route_name' => 'block_content.add_page',
'parent' => 'block.admin_display',
'weight' => -100
);
$links['entity.block_content.collection'] = array(
'title' => 'Custom block library',
'title' => t('Custom block library'),
'route_name' => 'entity.block_content.collection',
'parent' => 'block.admin_display',
);
$links['entity.block_content_type.collection'] = array(
'title' => 'Types',
'title' => t('Types'),
'route_name' => 'entity.block_content_type.collection',
'parent' => 'block.admin_display',
);
......@@ -367,7 +333,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
// If module contact is enabled.
if (\Drupal::moduleHandler()->moduleExists('contact')) {
$links['contact.form_add'] = array(
'title' => 'Add contact form',
'title' => t('Add contact form'),
'route_name' => 'contact.form_add',
'parent' => 'entity.contact_form.collection',
'weight' => -5
......@@ -376,70 +342,70 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
// If module update is enabled.
if (\Drupal::moduleHandler()->moduleExists('update')) {
$links['update.module_update'] = array(
'title' => 'Update',
'title' => t('Update'),
'route_name' => 'update.module_update',
'parent' => 'system.modules_list',
);
$links['update.module_install'] = array(
'title' => 'Install new module',
'title' => t('Install new module'),
'route_name' => 'update.module_install',
'parent' => 'system.modules_list',
);
}
if (\Drupal::moduleHandler()->moduleExists('devel')) {
$links['admin_development'] = array(
'title' => 'Development',
'title' => t('Development'),
'route_name' => 'system.admin_config_development',
'parent' => 'admin_toolbar_tools.help',
'weight' => -8
);
$links['devel.admin_settings'] = array(
'title' => 'Devel settings',
'title' => t('Devel settings'),
'route_name' => 'devel.admin_settings',
'parent' => 'admin_development'
);
$links['devel.configs_list'] = array(
'title' => 'Config editor',
'title' => t('Config editor'),
'route_name' => 'devel.configs_list',
'parent' => 'admin_development'
);
$links['devel.reinstall'] = array(
'title' => 'Reinstall Modules',
'title' => t('Reinstall modules'),
'route_name' => 'devel.reinstall',
'parent' => 'admin_development'
);
$links['devel.menu_rebuild'] = array(
'title' => 'Rebuild Menu',
'title' => t('Rebuild menu'),
'route_name' => 'devel.menu_rebuild',
'parent' => 'admin_development'
);
$links['devel.state_system_page'] = array(
'title' => 'State editor',
'title' => t('State editor'),
'route_name' => 'devel.state_system_page',
'parent' => 'admin_development'
);
$links['devel.theme_registry'] = array(
'title' => 'Theme registry',
'title' => t('Theme registry'),
'route_name' => 'devel.theme_registry',
'parent' => 'admin_development'
);
$links['devel.entity_info_page'] = array(
'title' => 'Entity Info',
'title' => t('Entity Info'),
'route_name' => 'devel.entity_info_page',
'parent' => 'admin_development'
);
$links['devel.execute_php'] = array(
'title' => 'Execute PHP',
'title' => t('Execute PHP'),
'route_name' => 'devel.execute_php',
'parent' => 'admin_development'
);
$links['devel.session'] = array(
'title' => 'View Session',
'title' => t('View session'),
'route_name' => 'devel.session',
'parent' => 'admin_development'
);
$links['devel.elements_page'] = array(
'title' => 'Hook_elements',
'title' => t('Hook_elements'),
'route_name' => 'devel.elements_page',
'parent' => 'admin_development'
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment