Loading src/GinNavigation.php +137 −70 Original line number Diff line number Diff line Loading @@ -74,9 +74,16 @@ class GinNavigation implements ContainerInjectionInterface { // Get the Entity Type Manager service. $entity_type_manager = \Drupal::entityTypeManager(); // Needs to be this syntax to // support older PHP versions // for Druapl 9.0+. $create_type_items = []; // Get node types. if ($entity_type_manager->hasDefinition('node')) { $content_types = $entity_type_manager->getStorage('node_type')->loadMultiple(); $content_type_items = []; foreach ($content_types as $item) { $content_type_items[] = [ 'title' => $item->label(), Loading @@ -84,9 +91,14 @@ class GinNavigation implements ContainerInjectionInterface { ]; } $create_type_items = array_merge($content_type_items); } // Get block types. if ($entity_type_manager->hasDefinition('block_content')) { $block_content_types = BlockContentType::loadMultiple(); $block_type_items = []; foreach ($block_content_types as $item) { $block_type_items[] = [ 'title' => $item->label(), Loading @@ -94,9 +106,23 @@ class GinNavigation implements ContainerInjectionInterface { ]; } $create_type_items = array_merge( $create_type_items, [ [ 'title' => t('Blocks'), 'url' => '', 'below' => $block_type_items, ], ] ); } // Get media types. if ($entity_type_manager->hasDefinition('media')) { $media_types = $entity_type_manager->getStorage('media_type')->loadMultiple(); $media_type_items = []; foreach ($media_types as $item) { $media_type_items[] = [ 'title' => $item->label(), Loading @@ -104,9 +130,23 @@ class GinNavigation implements ContainerInjectionInterface { ]; } $create_type_items = array_merge( $create_type_items, [ [ 'title' => t('Media'), 'url' => '', 'below' => $media_type_items, ], ] ); } // Get taxomony types. if ($entity_type_manager->hasDefinition('taxonomy_term')) { $taxonomy_types = Vocabulary::loadMultiple(); $taxonomy_type_items = []; foreach ($taxonomy_types as $item) { $taxonomy_type_items[] = [ 'title' => $item->label(), Loading @@ -114,22 +154,9 @@ class GinNavigation implements ContainerInjectionInterface { ]; } // Needs to be this syntax to // support older PHP versions // for Druapl 9.0+. $create_type_items = array_merge( $content_type_items, $create_type_items, [ [ 'title' => t('Blocks'), 'url' => '', 'below' => $block_type_items, ], [ 'title' => t('Media'), 'url' => '', 'below' => $media_type_items, ], [ 'title' => t('Taxonomy'), 'url' => '', Loading @@ -137,7 +164,9 @@ class GinNavigation implements ContainerInjectionInterface { ], ] ); } // Generate menu items. $create_items = [ [ 'title' => t('Create'), Loading @@ -145,6 +174,7 @@ class GinNavigation implements ContainerInjectionInterface { 'below' => $create_type_items, ], ]; return [ '#theme' => 'menu_region__middle', '#items' => $create_items, Loading @@ -157,27 +187,64 @@ class GinNavigation implements ContainerInjectionInterface { * Get Navigation Content menu. */ public function getNavigationContentMenuItems(): array { $content_items = [ $entity_type_manager = \Drupal::entityTypeManager(); $create_content_items = []; // Get Content menu item. if ($entity_type_manager->hasDefinition('node')) { $create_content_items = [ [ 'title' => t('Content'), 'url' => Url::fromRoute('system.admin_content')->toString(), ], ]; $create_content_items = array_merge($create_content_items); } // Get Blocks menu item. if ($entity_type_manager->hasDefinition('block_content')) { $create_content_items = array_merge( $create_content_items, [ [ 'title' => t('Blocks'), 'url' => Url::fromRoute('entity.block_content.collection')->toString(), ], ] ); } // Get File menu item. if ($entity_type_manager->hasDefinition('file')) { $create_content_items = array_merge( $create_content_items, [ [ 'title' => t('Files'), 'url' => '/admin/content/files', ], ] ); } // Get Media menu item. if ($entity_type_manager->hasDefinition('media')) { $create_content_items = array_merge( $create_content_items, [ [ 'title' => t('Media'), 'url' => '/admin/content/media', ], ]; ] ); } return [ '#theme' => 'menu_region__middle', '#items' => $content_items, '#items' => $create_content_items, '#menu_name' => 'content', '#title' => t('Content Navigation'), ]; Loading templates/menu-region--bottom.html.twig +2 −0 Original line number Diff line number Diff line Loading @@ -8,11 +8,13 @@ <span id="sidebar-state" class="toolbar-link__label">{{ 'Collapse sidebar'|t }}</span> </button> </li> {% if help_enabled %} <li class="toolbar-menu__item toolbar-menu__item--level-1"> <a href="{{ path('help.main') }}" class="toolbar-link toolbar-link--has-icon toolbar-link--help"> <span>{{ 'Help'|t }}</span> </a> </li> {% endif %} <li class="toolbar-menu__item toolbar-menu__item--has-dropdown toolbar-menu__item--user toolbar-menu__item--level-1"> <button class="toolbar-link toolbar-link--has-icon toolbar-link--{{ menu_name|clean_class }}" data-url="{{ url }}"> <span class="toolbar-link__action">{{ 'Extend'|t }}</span> Loading Loading
src/GinNavigation.php +137 −70 Original line number Diff line number Diff line Loading @@ -74,9 +74,16 @@ class GinNavigation implements ContainerInjectionInterface { // Get the Entity Type Manager service. $entity_type_manager = \Drupal::entityTypeManager(); // Needs to be this syntax to // support older PHP versions // for Druapl 9.0+. $create_type_items = []; // Get node types. if ($entity_type_manager->hasDefinition('node')) { $content_types = $entity_type_manager->getStorage('node_type')->loadMultiple(); $content_type_items = []; foreach ($content_types as $item) { $content_type_items[] = [ 'title' => $item->label(), Loading @@ -84,9 +91,14 @@ class GinNavigation implements ContainerInjectionInterface { ]; } $create_type_items = array_merge($content_type_items); } // Get block types. if ($entity_type_manager->hasDefinition('block_content')) { $block_content_types = BlockContentType::loadMultiple(); $block_type_items = []; foreach ($block_content_types as $item) { $block_type_items[] = [ 'title' => $item->label(), Loading @@ -94,9 +106,23 @@ class GinNavigation implements ContainerInjectionInterface { ]; } $create_type_items = array_merge( $create_type_items, [ [ 'title' => t('Blocks'), 'url' => '', 'below' => $block_type_items, ], ] ); } // Get media types. if ($entity_type_manager->hasDefinition('media')) { $media_types = $entity_type_manager->getStorage('media_type')->loadMultiple(); $media_type_items = []; foreach ($media_types as $item) { $media_type_items[] = [ 'title' => $item->label(), Loading @@ -104,9 +130,23 @@ class GinNavigation implements ContainerInjectionInterface { ]; } $create_type_items = array_merge( $create_type_items, [ [ 'title' => t('Media'), 'url' => '', 'below' => $media_type_items, ], ] ); } // Get taxomony types. if ($entity_type_manager->hasDefinition('taxonomy_term')) { $taxonomy_types = Vocabulary::loadMultiple(); $taxonomy_type_items = []; foreach ($taxonomy_types as $item) { $taxonomy_type_items[] = [ 'title' => $item->label(), Loading @@ -114,22 +154,9 @@ class GinNavigation implements ContainerInjectionInterface { ]; } // Needs to be this syntax to // support older PHP versions // for Druapl 9.0+. $create_type_items = array_merge( $content_type_items, $create_type_items, [ [ 'title' => t('Blocks'), 'url' => '', 'below' => $block_type_items, ], [ 'title' => t('Media'), 'url' => '', 'below' => $media_type_items, ], [ 'title' => t('Taxonomy'), 'url' => '', Loading @@ -137,7 +164,9 @@ class GinNavigation implements ContainerInjectionInterface { ], ] ); } // Generate menu items. $create_items = [ [ 'title' => t('Create'), Loading @@ -145,6 +174,7 @@ class GinNavigation implements ContainerInjectionInterface { 'below' => $create_type_items, ], ]; return [ '#theme' => 'menu_region__middle', '#items' => $create_items, Loading @@ -157,27 +187,64 @@ class GinNavigation implements ContainerInjectionInterface { * Get Navigation Content menu. */ public function getNavigationContentMenuItems(): array { $content_items = [ $entity_type_manager = \Drupal::entityTypeManager(); $create_content_items = []; // Get Content menu item. if ($entity_type_manager->hasDefinition('node')) { $create_content_items = [ [ 'title' => t('Content'), 'url' => Url::fromRoute('system.admin_content')->toString(), ], ]; $create_content_items = array_merge($create_content_items); } // Get Blocks menu item. if ($entity_type_manager->hasDefinition('block_content')) { $create_content_items = array_merge( $create_content_items, [ [ 'title' => t('Blocks'), 'url' => Url::fromRoute('entity.block_content.collection')->toString(), ], ] ); } // Get File menu item. if ($entity_type_manager->hasDefinition('file')) { $create_content_items = array_merge( $create_content_items, [ [ 'title' => t('Files'), 'url' => '/admin/content/files', ], ] ); } // Get Media menu item. if ($entity_type_manager->hasDefinition('media')) { $create_content_items = array_merge( $create_content_items, [ [ 'title' => t('Media'), 'url' => '/admin/content/media', ], ]; ] ); } return [ '#theme' => 'menu_region__middle', '#items' => $content_items, '#items' => $create_content_items, '#menu_name' => 'content', '#title' => t('Content Navigation'), ]; Loading
templates/menu-region--bottom.html.twig +2 −0 Original line number Diff line number Diff line Loading @@ -8,11 +8,13 @@ <span id="sidebar-state" class="toolbar-link__label">{{ 'Collapse sidebar'|t }}</span> </button> </li> {% if help_enabled %} <li class="toolbar-menu__item toolbar-menu__item--level-1"> <a href="{{ path('help.main') }}" class="toolbar-link toolbar-link--has-icon toolbar-link--help"> <span>{{ 'Help'|t }}</span> </a> </li> {% endif %} <li class="toolbar-menu__item toolbar-menu__item--has-dropdown toolbar-menu__item--user toolbar-menu__item--level-1"> <button class="toolbar-link toolbar-link--has-icon toolbar-link--{{ menu_name|clean_class }}" data-url="{{ url }}"> <span class="toolbar-link__action">{{ 'Extend'|t }}</span> Loading