Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / admin_toolbar / admin_toolbar_tools / admin_toolbar_tools.module
1 <?php
2
3 /**
4  * @file
5  * Provides extra menu links for the core drupal toolbar.
6  */
7
8 use Drupal\Core\Routing\RouteMatchInterface;
9 use Drupal\Core\Url;
10
11 /**
12  * Implements hook_toolbar().
13  */
14 function admin_toolbar_tools_toolbar() {
15   $items = [];
16   $items['admin_toolbar_tools'] = [
17     '#type' => 'toolbar_item',
18     'tab' => [
19       '#type' => 'link',
20       '#attributes' => [
21         'class' => ['toolbar-icon', 'toolbar-icon-admin-toolbar-tools-help'],
22       ],
23     ],
24     '#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']],
25   ];
26
27   return $items;
28 }
29
30 /**
31  * Implements hook_help().
32  */
33 function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) {
34   switch ($route_name) {
35     case 'help.page.admin_toolbar_tools':
36       $output = '';
37       $output .= '<p>';
38       $output .= t('The Admin Toolbar Extra Tools module comes packaged with the <a href=":admin-toolbar">Admin Toolbar</a> module and adds functionality to it. The additional functionality is accessed thru extra links on the main administration Toolbar. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page.</a>', [':admin-toolbar' => Url::fromRoute('help.page', ['name' => 'admin_toolbar'])->toString()]);
39       $output .= '</p>';
40       $output .= '<h3>' . t('Uses') . '</h3>';
41       $output .= '<p>' . t('To use Admin Toolbar Extra Tools just install it like any other module. There is no other configuration required.') . '</p>';
42
43       return $output;
44   }
45 }
46
47 /**
48  * Implements hook_menu_links_discovered_alter().
49  */
50 function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
51   $moduleHandler = \Drupal::moduleHandler();
52   $entityTypeManager = \Drupal::entityTypeManager();
53   $routeProvider = \Drupal::service('router.route_provider');
54   $routes = [];
55   foreach ($routeProvider->getAllRoutes() as $route_name => $route) {
56     $routes[] = $route_name;
57   }
58
59   $entityTypes = $entityTypeManager->getDefinitions();
60   $content_entities = [];
61   foreach ($entityTypes as $key => $entityType) {
62     if ($entityType->getBundleEntityType() && ($entityType->get('field_ui_base_route') != '')) {
63       $content_entities[$key] = [
64         'content_entity' => $key,
65         'content_entity_bundle' => $entityType->getBundleEntityType(),
66       ];
67     }
68   }
69
70   // Adding a menu link to clean the Views cache.
71   if ($moduleHandler->moduleExists('views')) {
72     $links['admin_toolbar_tools.flush_views'] = [
73       'title' => t('Flush views cache'),
74       'route_name' => 'admin_toolbar_tools.flush_views',
75       'menu_name' => 'admin',
76       'parent' => 'admin_toolbar_tools.flush',
77     ];
78     // Adding a menu link to Files.
79     if ($moduleHandler->moduleExists('file') && in_array('view.files.page_1', $routes)) {
80       $links['admin_toolbar_tools.view.files'] = [
81         'title' => t('Files'),
82         'route_name' => 'view.files.page_1',
83         'menu_name' => 'admin',
84         'parent' => 'system.admin_content',
85       ];
86     }
87   }
88
89   // Adds common links to entities.
90   foreach ($content_entities as $entities) {
91     $content_entity_bundle = $entities['content_entity_bundle'];
92     $content_entity = $entities['content_entity'];
93     foreach ($entityTypeManager->getStorage($content_entity_bundle)->loadMultiple() as $machine_name => $bundle) {
94       // Normally, the edit form for the bundle would be its root link.
95       $content_entity_bundle_root = NULL;
96       if (in_array('entity.' . $content_entity_bundle . '.overview_form', $routes)) {
97         // Some bundles have an overview/list form that make a better root link.
98         $content_entity_bundle_root = 'entity.' . $content_entity_bundle . '.overview_form.' . $machine_name;
99         $links[$content_entity_bundle_root] = [
100           'title' => t($bundle->label()),
101           'route_name' => 'entity.' . $content_entity_bundle . '.overview_form',
102           'menu_name' => 'admin',
103           'parent' => 'entity.' . $content_entity_bundle . '.collection',
104           'route_parameters' => [$content_entity_bundle => $machine_name],
105         ];
106       }
107       if (in_array('entity.' . $content_entity_bundle . '.edit_form', $routes)) {
108         $key = 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name;
109         $links[$key] = [
110           'title' => t($bundle->label()),
111           'route_name' => 'entity.' . $content_entity_bundle . '.edit_form',
112           'menu_name' => 'admin',
113           'parent' => 'entity.' . $content_entity_bundle . '.collection',
114           'route_parameters' => [$content_entity_bundle => $machine_name],
115         ];
116         if (empty($content_entity_bundle_root)) {
117           $content_entity_bundle_root = $key;
118         }
119         else {
120           $links[$key]['parent'] = $content_entity_bundle_root;
121           $links[$key]['title'] = t('Edit');
122         }
123       }
124       if ($moduleHandler->moduleExists('field_ui')) {
125         if (in_array('entity.' . $content_entity . '.field_ui_fields', $routes)) {
126           $links['entity.' . $content_entity . '.field_ui_fields' . $machine_name] = [
127             'title' => t('Manage fields'),
128             'route_name' => 'entity.' . $content_entity . '.field_ui_fields',
129             'menu_name' => 'admin',
130             'parent' => $content_entity_bundle_root,
131             'route_parameters' => [$content_entity_bundle => $machine_name],
132             'weight' => 1,
133           ];
134         }
135         if (in_array('entity.entity_form_display.' . $content_entity . '.default', $routes)) {
136           $links['entity.entity_form_display.' . $content_entity . '.default' . $machine_name] = [
137             'title' => t('Manage form display'),
138             'route_name' => 'entity.entity_form_display.' . $content_entity . '.default',
139             'menu_name' => 'admin',
140             'parent' => $content_entity_bundle_root,
141             'route_parameters' => [$content_entity_bundle => $machine_name],
142             'weight' => 2,
143           ];
144         }
145         if (in_array('entity.entity_view_display.' . $content_entity . '.default', $routes)) {
146           $links['entity.entity_view_display.' . $content_entity . '.default.' . $machine_name] = [
147             'title' => t('Manage display'),
148             'route_name' => 'entity.entity_view_display.' . $content_entity . '.default',
149             'menu_name' => 'admin',
150             'parent' => $content_entity_bundle_root,
151             'route_parameters' => [$content_entity_bundle => $machine_name],
152             'weight' => 3,
153           ];
154         }
155       }
156       if ($moduleHandler->moduleExists('devel') && in_array('entity.' . $content_entity_bundle . '.devel_load', $routes)) {
157         $links['entity.' . $content_entity_bundle . '.devel_load.' . $machine_name] = [
158           'title' => t('Devel'),
159           'route_name' => 'entity.' . $content_entity_bundle . '.devel_load',
160           'menu_name' => 'admin',
161           'parent' => $content_entity_bundle_root,
162           'route_parameters' => [$content_entity_bundle => $machine_name],
163           'weight' => 4,
164         ];
165       }
166       if (in_array('entity.' . $content_entity_bundle . '.delete_form', $routes)) {
167         $links['entity.' . $content_entity_bundle . '.delete_form.' . $machine_name] = [
168           'title' => t('Delete'),
169           'route_name' => 'entity.' . $content_entity_bundle . '.delete_form',
170           'menu_name' => 'admin',
171           'parent' => $content_entity_bundle_root,
172           'route_parameters' => [$content_entity_bundle => $machine_name],
173           'weight' => 5,
174         ];
175       }
176     }
177   }
178
179   // Add user links.
180   $links['user.admin_create'] = [
181     'title' => t('Add a new user'),
182     'route_name' => 'user.admin_create',
183     'menu_name' => 'admin',
184     'parent' => 'entity.user.collection',
185   ];
186   $links['user.admin_permissions'] = [
187     'title' => t('Permissions'),
188     'route_name' => 'user.admin_permissions',
189     'menu_name' => 'admin',
190     'parent' => 'entity.user.collection',
191   ];
192   $links['entity.user_role.collection'] = [
193     'title' => t('Roles'),
194     'route_name' => 'entity.user_role.collection',
195     'menu_name' => 'admin',
196     'parent' => 'entity.user.collection',
197   ];
198   $links['admin_toolbar_tools.user.logout'] = [
199     'title' => t('Logout'),
200     'route_name' => 'user.logout',
201     'parent' => 'admin_toolbar_tools.help',
202     'weight' => 10,
203   ];
204   $links['user.role_add'] = [
205     'title' => t('Add a new role'),
206     'route_name' => 'user.role_add',
207     'menu_name' => 'admin',
208     'parent' => 'entity.user_role.collection',
209     'weight' => -5,
210   ];
211   if ($moduleHandler->moduleExists('field_ui')) {
212     $links['entity.user.field_ui_fields_'] = [
213       'title' => t('Manage fields'),
214       'route_name' => 'entity.user.field_ui_fields',
215       'menu_name' => 'admin',
216       'parent' => 'entity.user.admin_form',
217     ];
218     $links['entity.entity_form_display.user.default_'] = [
219       'title' => t('Manage form display'),
220       'route_name' => 'entity.entity_form_display.user.default',
221       'menu_name' => 'admin',
222       'parent' => 'entity.user.admin_form',
223     ];
224     $links['entity.entity_view_display.user.default_'] = [
225       'title' => t('Manage display'),
226       'route_name' => 'entity.entity_view_display.user.default',
227       'menu_name' => 'admin',
228       'parent' => 'entity.user.admin_form',
229     ];
230   }
231   foreach (user_roles() as $role) {
232     $links['entity.user_role.edit_form.' . $role->id()] = [
233       'title' => t($role->label()),
234       'route_name' => 'entity.user_role.edit_form',
235       'menu_name' => 'admin',
236       'parent' => 'entity.user_role.collection',
237       'route_parameters' => ['user_role' => $role->id()],
238     ];
239     $links['entity.user_role.edit_permissions_form.' . $role->id()] = [
240       'title' => t('Edit permissions'),
241       'route_name' => 'entity.user_role.edit_permissions_form',
242       'menu_name' => 'admin',
243       'parent' => 'entity.user_role.edit_form.' . $role->id(),
244       'route_parameters' => ['user_role' => $role->id()],
245     ];
246     $links['entity.user_role.delete_form.' . $role->id()] = [
247       'title' => t('Delete'),
248       'route_name' => 'entity.user_role.delete_form',
249       'menu_name' => 'admin',
250       'parent' => 'entity.user_role.edit_form.' . $role->id(),
251       'route_parameters' => ['user_role' => $role->id()],
252     ];
253     if ($moduleHandler->moduleExists('devel')) {
254       $links['entity.user_role.devel_load.' . $role->id()] = [
255         'title' => t('Devel'),
256         'route_name' => 'entity.user_role.devel_load',
257         'menu_name' => 'admin',
258         'parent' => 'entity.user_role.edit_form.' . $role->id(),
259         'route_parameters' => ['user_role' => $role->id()],
260       ];
261     }
262   }
263
264   if ($moduleHandler->moduleExists('node')) {
265     $links['admin_toolbar_tools.add_content'] = $links['node.add_page'];
266     $links['admin_toolbar_tools.add_content']['parent'] = 'system.admin_content';
267     $links['node.type_add'] = [
268       'title' => t('Add content type'),
269       'route_name' => 'node.type_add',
270       'menu_name' => 'admin',
271       'parent' => 'entity.node_type.collection',
272       'weight' => -5,
273     ];
274     // Add node links for each content type.
275     foreach ($entityTypeManager->getStorage('node_type')->loadMultiple() as $type) {
276       $links['node.add.' . $type->id()] = [
277         'title' => t($type->label()),
278         'route_name' => 'node.add',
279         'parent' => 'admin_toolbar_tools.add_content',
280         'route_parameters' => ['node_type' => $type->id()],
281       ];
282     }
283   }
284
285   if ($moduleHandler->moduleExists('field_ui')) {
286     $links['field_ui.entity_form_mode_add'] = [
287       'title' => t('Add new form mode'),
288       'route_name' => 'field_ui.entity_form_mode_add',
289       'menu_name' => 'admin',
290       'parent' => 'entity.entity_form_mode.collection',
291     ];
292     $links['field_ui.entity_view_mode_add'] = [
293       'title' => t('Add new view mode'),
294       'route_name' => 'field_ui.entity_view_mode_add',
295       'menu_name' => 'admin',
296       'parent' => 'entity.entity_view_mode.collection',
297     ];
298   }
299
300   if ($moduleHandler->moduleExists('taxonomy')) {
301     $links['entity.taxonomy_vocabulary.add_form'] = [
302       'title' => t('Add vocabulary'),
303       'route_name' => 'entity.taxonomy_vocabulary.add_form',
304       'menu_name' => 'admin',
305       'parent' => 'entity.taxonomy_vocabulary.collection',
306       'weight' => -5,
307     ];
308   }
309
310   if ($moduleHandler->moduleExists('menu_ui')) {
311     $links['entity.menu.add_form'] = [
312       'title' => t('Add menu'),
313       'route_name' => 'entity.menu.add_form',
314       'menu_name' => 'admin',
315       'parent' => 'entity.menu.collection',
316       'weight' => -50,
317     ];
318     // Adds links to /admin/structure/menu.
319     foreach (menu_ui_get_menus() as $machine_name => $label) {
320       $links['entity.menu.edit_form.' . $machine_name] = [
321         'title' => t($label),
322         'route_name' => 'entity.menu.edit_form',
323         'menu_name' => 'admin',
324         'parent' => 'entity.menu.collection',
325         'route_parameters' => ['menu' => $machine_name],
326       ];
327       $links['entity.menu.delete_form.' . $machine_name] = [
328         'title' => t('Delete'),
329         'route_name' => 'entity.menu.delete_form',
330         'menu_name' => 'admin',
331         'parent' => 'entity.menu.edit_form.' . $machine_name,
332         'route_parameters' => ['menu' => $machine_name],
333       ];
334       if ($moduleHandler->moduleExists('devel')) {
335         $links['entity.menu.devel_load.' . $machine_name] = [
336           'title' => t('Devel'),
337           'route_name' => 'entity.menu.devel_load',
338           'menu_name' => 'admin',
339           'parent' => 'entity.menu.edit_form.' . $machine_name,
340           'route_parameters' => ['menu' => $machine_name],
341         ];
342       }
343       $links['entity.menu.add_link_form.' . $machine_name] = [
344         'title' => t('Add link'),
345         'route_name' => 'entity.menu.add_link_form',
346         'menu_name' => 'admin',
347         'parent' => 'entity.menu.edit_form.' . $machine_name,
348         'route_parameters' => ['menu' => $machine_name],
349       ];
350     }
351   }
352
353   // If module block_content is enabled.
354   if ($moduleHandler->moduleExists('block_content')) {
355     $links['block_content.add_page'] = [
356       'title' => t('Add custom block'),
357       'route_name' => 'block_content.add_page',
358       'menu_name' => 'admin',
359       'parent' => 'block.admin_display',
360       'weight' => -100,
361     ];
362     $links['entity.block_content.collection'] = [
363       'title' => t('Custom block library'),
364       'route_name' => 'entity.block_content.collection',
365       'menu_name' => 'admin',
366       'parent' => 'block.admin_display',
367     ];
368     $links['entity.block_content_type.collection'] = [
369       'title' => t('Types'),
370       'route_name' => 'entity.block_content_type.collection',
371       'menu_name' => 'admin',
372       'parent' => 'block.admin_display',
373     ];
374   }
375
376   // If module Contact is enabled.
377   if ($moduleHandler->moduleExists('contact')) {
378     $links['contact.form_add'] = [
379       'title' => t('Add contact form'),
380       'route_name' => 'contact.form_add',
381       'menu_name' => 'admin',
382       'parent' => 'entity.contact_form.collection',
383       'weight' => -5,
384     ];
385   }
386
387   // If module Update Manager is enabled.
388   if ($moduleHandler->moduleExists('update')) {
389     $links['update.module_update'] = [
390       'title' => t('Update'),
391       'route_name' => 'update.module_update',
392       'menu_name' => 'admin',
393       'parent' => 'system.modules_list',
394     ];
395     $links['update.module_install'] = [
396       'title' => t('Install new module'),
397       'route_name' => 'update.module_install',
398       'menu_name' => 'admin',
399       'parent' => 'system.modules_list',
400     ];
401   }
402
403   // If module Devel is enabled.
404   if ($moduleHandler->moduleExists('devel')) {
405     $links['admin_development'] = [
406       'title' => t('Development'),
407       'route_name' => 'system.admin_config_development',
408       'menu_name' => 'admin',
409       'parent' => 'admin_toolbar_tools.help',
410       'weight' => '-8',
411     ];
412     $links['admin_toolbar_tools.devel.admin_settings'] = [
413       'title' => t('Devel settings'),
414       'route_name' => 'devel.admin_settings',
415       'menu_name' => 'admin',
416       'parent' => 'admin_development',
417       'weight' => '-1',
418     ];
419     if ($moduleHandler->moduleExists('webprofiler')) {
420       $links['admin_toolbar_tools.devel.webprofiler'] = [
421         'title' => t('Web Profiler settings'),
422         'route_name' => 'webprofiler.settings',
423         'menu_name' => 'admin',
424         'parent' => 'admin_development',
425       ];
426     }
427     $links['admin_toolbar_tools.devel.configs_list'] = [
428       'title' => t('Config editor'),
429       'route_name' => 'devel.configs_list',
430       'menu_name' => 'admin',
431       'parent' => 'admin_development',
432     ];
433     $links['admin_toolbar_tools.devel.reinstall'] = [
434       'title' => t('Reinstall modules'),
435       'route_name' => 'devel.reinstall',
436       'parent' => 'admin_development',
437     ];
438     $links['admin_toolbar_tools.devel.menu_rebuild'] = [
439       'title' => t('Rebuild menu'),
440       'route_name' => 'devel.menu_rebuild',
441       'menu_name' => 'admin',
442       'parent' => 'admin_development',
443     ];
444     $links['admin_toolbar_tools.devel.state_system_page'] = [
445       'title' => t('State editor'),
446       'route_name' => 'devel.state_system_page',
447       'menu_name' => 'admin',
448       'parent' => 'admin_development',
449     ];
450     $links['admin_toolbar_tools.devel.theme_registry'] = [
451       'title' => t('Theme registry'),
452       'route_name' => 'devel.theme_registry',
453       'menu_name' => 'admin',
454       'parent' => 'admin_development',
455     ];
456     $links['admin_toolbar_tools.devel.entity_info_page'] = [
457       'title' => t('Entity Info'),
458       'route_name' => 'devel.entity_info_page',
459       'menu_name' => 'admin',
460       'parent' => 'admin_development',
461     ];
462     $links['admin_toolbar_tools.devel.execute_php'] = [
463       'title' => t('Execute PHP Code'),
464       'route_name' => 'devel.execute_php',
465       'menu_name' => 'admin',
466       'parent' => 'admin_development',
467     ];
468     $links['admin_toolbar_tools.devel.session'] = [
469       'title' => t('Session viewer'),
470       'route_name' => 'devel.session',
471       'menu_name' => 'admin',
472       'parent' => 'admin_development',
473     ];
474     $links['admin_toolbar_tools.devel.elements_page'] = [
475       'title' => t('Form API field types'),
476       'route_name' => 'devel.elements_page',
477       'menu_name' => 'admin',
478       'parent' => 'admin_development',
479     ];
480     // Menu link for the Toolbar module.
481     $links['admin_toolbar_tools.toolbar.settings'] = [
482       'title' => t('Toolbar settings'),
483       'route_name' => 'devel.toolbar.settings_form',
484       'menu_name' => 'admin',
485       'parent' => 'devel.admin_settings',
486     ];
487   }
488
489   // If module Views Ui enabled.
490   if ($moduleHandler->moduleExists('views_ui')) {
491     $links['admin_toolbar_tools.views_ui.add'] = [
492       'title' => t('Add new view'),
493       'route_name' => 'views_ui.add',
494       'menu_name' => 'admin',
495       'parent' => 'entity.view.collection',
496       'weight' => -5,
497     ];
498     $links['admin_toolbar_tools.views_ui.field_list'] = [
499       'title' => t('Used in views'),
500       'route_name' => 'views_ui.reports_fields',
501       'menu_name' => 'admin',
502       'parent' => 'entity.field_storage_config.collection',
503     ];
504   }
505
506   $links['admin_toolbar_tools.system.theme_settings'] = [
507     'title' => t('Settings'),
508     'route_name' => 'system.theme_settings',
509     'menu_name' => 'admin',
510     'parent' => 'system.themes_page',
511   ];
512
513   if ($moduleHandler->moduleExists('webprofiler')) {
514     $links['admin_toolbar_tools.devel.webprofiler'] = [
515       'title' => t('Webprofiler settings'),
516       'route_name' => 'webprofiler.settings',
517       'menu_name' => 'admin',
518       'parent' => 'admin_development',
519     ];
520   }
521
522   if ($moduleHandler->moduleExists('update')) {
523     $links['update.theme_install_'] = [
524       'title' => t('Install new theme'),
525       'route_name' => 'update.theme_install',
526       'menu_name' => 'admin',
527       'parent' => 'system.themes_page',
528     ];
529     $links['update.theme_update_'] = [
530       'title' => t('Update'),
531       'route_name' => 'update.theme_update',
532       'menu_name' => 'admin',
533       'parent' => 'system.themes_page',
534     ];
535     // Lists installed themes.
536     $installed_themes = admin_toolbar_tools_installed_themes();
537     foreach ($installed_themes as $key_theme => $label_theme) {
538       $links['system.theme_settings_theme.' . $key_theme] = [
539         'title' => t($label_theme),
540         'route_name' => 'system.theme_settings_theme',
541         'menu_name' => 'admin',
542         'parent' => 'system.theme_settings_',
543         'route_parameters' => [
544           'theme' => $key_theme,
545         ],
546       ];
547     }
548   }
549
550   // If module Language enabled.
551   if ($moduleHandler->moduleExists('language')) {
552     $links['admin_toolbar_tools.language.negotiation'] = [
553       'title' => t('Detection and selection'),
554       'route_name' => 'language.negotiation',
555       'menu_name' => 'admin',
556       'parent' => 'entity.configurable_language.collection',
557     ];
558   }
559
560   // If module Media enabled.
561   if ($moduleHandler->moduleExists('media')) {
562     $links['admin_toolbar_tools.add_media'] = [
563       'title' => t('Add media'),
564       'route_name' => 'entity.media.add_page',
565       'menu_name' => 'admin',
566       'parent' => 'system.admin_content',
567     ];
568     // Add node links for each media type.
569     foreach (\Drupal::entityTypeManager()->getStorage('media_type')->loadMultiple() as $type) {
570       $links['media.add.' . $type->id()] = [
571         'title' => t($type->label()),
572         'route_name' => 'entity.media.add_form',
573         'parent' => 'admin_toolbar_tools.add_media',
574         'route_parameters' => ['media_type' => $type->id()],
575       ];
576     }
577   }
578
579   // If module Config enabled.
580   if ($moduleHandler->moduleExists('config')) {
581     $links['admin_toolbar_tools.config.import'] = [
582       'title' => t('Import'),
583       'route_name' => 'config.import_full',
584       'menu_name' => 'admin',
585       'parent' => 'config.sync',
586       'weight' => 1,
587     ];
588     $links['admin_toolbar_tools.config.export'] = [
589       'title' => t('Export'),
590       'route_name' => 'config.export_full',
591       'menu_name' => 'admin',
592       'parent' => 'config.sync',
593       'weight' => 2,
594     ];
595   }
596 }
597
598 /**
599  * Return installed themes.
600  *
601  * @return array
602  *   An array of friendly theme names, keyed by the machine name.
603  */
604 function admin_toolbar_tools_installed_themes() {
605   $themeHandler = \Drupal::service('theme_handler');
606   $all_themes = $themeHandler->listInfo();
607   $themes_installed = [];
608   foreach ($all_themes as $key_theme => $theme) {
609     if ($themeHandler->hasUi($key_theme)) {
610       $themes_installed[$key_theme] = $themeHandler->getName($key_theme);
611     }
612   }
613
614   return $themes_installed;
615 }
616
617 /**
618  * Get all links related to entity.
619  *
620  * @param string $entity_type_id
621  *   The machine name for the entity type.
622  *
623  * @return array
624  *   The links for the entity type.
625  */
626 function admin_toolbar_tools_get_links($entity_type_id) {
627   $entity = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
628   // Get all links related to entity.
629   $links = $entity->getLinkTemplates();
630
631   return $links;
632 }