Commit dae0947b authored by Nicolas Morand's avatar Nicolas Morand Committed by Sascha Eggenberger
Browse files

Resolve #3395738 "Fatal error when enabling the new experimental sidebar...

Resolve #3395738 "Fatal error when enabling the new experimental sidebar navigation with node module disabled"
parent 4ee76384
Loading
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -87,9 +87,11 @@ class GinNavigation implements ContainerInjectionInterface {
    // support older PHP versions
    // for Druapl 9.0+.
    $create_type_items = [];
    $create_item_url = '';

    // Get node types.
    if ($entity_type_manager->hasDefinition('node')) {
      $create_item_url = Url::fromRoute('node.add_page')->toString();
      $content_types = $entity_type_manager->getStorage('node_type')->loadMultiple();
      $content_type_items = [];

@@ -97,7 +99,7 @@ class GinNavigation implements ContainerInjectionInterface {
        $content_type_items[] = [
          'title' => $item->label(),
          'class' => $item->id(),
          'url' => Url::fromRoute('node.add', ['node_type' => $item->id()]),
          'url' => $create_item_url,
        ];
      }

@@ -182,11 +184,15 @@ class GinNavigation implements ContainerInjectionInterface {
      );
    }

    if (!$create_type_items && !$create_item_url) {
      return [];
    }

    // Generate menu items.
    $create_items['create'] = [
      'title' => t('Create'),
      'class' => 'create',
      'url' => Url::fromRoute('node.add_page')->toString(),
      'url' => $create_item_url,
      'below' => $create_type_items,
    ];

+9 −3
Original line number Diff line number Diff line
@@ -12,9 +12,15 @@
    {% set item_class = 'toolbar-link--' ~ item.class|clean_class %}
    <li id="{{ item_id }}" class="{{ item.below ? 'toolbar-menu__item--has-dropdown' }} toolbar-menu__item toolbar-menu__item--level-1" data-url="{{ item.url }}">
      {% if item.below is empty %}
        {% if item.url %}
          <a href="{{ item.url }}" class="toolbar-link toolbar-link--has-icon {{ item_class }}">
            <span>{{ item.title }}</span>
          </a>
        {% else %}
          <button class="toolbar-link toolbar-link--has-icon {{ item_class }}">
            <span>{{ item.title }}</span>
          </button>
        {% endif %}
      {% endif %}
    {% if item.below %}
      <button class="toolbar-link toolbar-link--has-icon {{ item_class }}">