Commit 4e66cd7c authored by Sascha Eggenberger's avatar Sascha Eggenberger
Browse files

Add active trail paths and fix code styles

parent c6166624
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@

Helper module to bring the Gin toolbar into the Frontend of your site. Requires the [Gin Admin Theme](https://drupal.org/project/gin).

This module is needed due to some technical limitations of Drupal (Admin) themes.
This module is needed due to some technical limitations of
Drupal (Admin) themes.

- For a full description of the module, visit the [project page](https://www.drupal.org/project/gin_toolbar).
- Use the [Issue queue](https://www.drupal.org/project/issues/gin_toolbar) to submit bug reports and feature suggestions, or track changes.
+3 −2
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@ function gin_toolbar_requirements($phase) {
  // Check if Drupal should be installed and gin in is in the install profile.
  if (InstallerKernel::installationAttempted()
    && isset($install_state['profile_info']['themes'])
    && in_array('gin', $install_state['profile_info']['themes'], TRUE)) {
    && in_array('gin', $install_state['profile_info']['themes'], TRUE)
  ) {
    return $requirements;
  }

+2 −2
Original line number Diff line number Diff line
@@ -8,9 +8,9 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\gin_toolbar\Render\Element\GinToolbar;
use Drupal\gin\GinUserPicture;
use Drupal\gin\GinSettings;
use Drupal\gin\GinUserPicture;
use Drupal\gin_toolbar\Render\Element\GinToolbar;

/**
 * Implements hook_preprocess_HOOK() for html.
+78 −7
Original line number Diff line number Diff line
@@ -5,9 +5,7 @@ namespace Drupal\gin_toolbar\Menu;
use Drupal\Core\Menu\MenuActiveTrail;

/**
 * Class GinToolbarActiveTrail.
 *
 * @package Drupal\gin_toolbar\Menu
 * Handles the active trail.
 */
class GinToolbarActiveTrail extends MenuActiveTrail {

@@ -20,6 +18,20 @@ class GinToolbarActiveTrail extends MenuActiveTrail {
    $route_name = $this->routeMatch->getRouteName();
    $route_params = $this->routeMatch->getRawParameters()->all();

    // Content.
    if (in_array($route_name, [
      'system.admin_content',
      'node.add_page',
      'entity.node.canonical',
      'entity.node.edit_form',
    ])) {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['system.admin_content', []],
      ]);
    }

    // Create Content.
    if ($route_name === 'node.add') {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
@@ -28,17 +40,76 @@ class GinToolbarActiveTrail extends MenuActiveTrail {
      ]);
    }

    if ($route_name === 'node.add_page') {
    // Media.
    if (in_array($route_name, [
      'view.media_library.page',
      'entity.media.collection',
      'entity.media.add_page',
      'entity.media.add_form',
    ])) {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['system.admin_content', []],
            ['entity.media.collection', []],
      ]);
    }

    if (in_array($route_name, ['entity.node.canonical', 'entity.node.edit_form'])) {
    // Create Media.
    if ($route_name === 'entity.media.add_form') {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['system.admin_content', []],
            ['entity.media.add_page', []],
            ['entity.media.collection', []],
      ]);
    }

    // Files.
    if ($route_name === 'view.files.page_1') {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['view.files.page_1 ', []],
      ]);
    }

    // Blocks.
    if ($route_name === 'entity.block_content.collection') {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['entity.block_content.collection', []],
      ]);
    }

    // User.
    if (in_array($route_name, [
      'entity.user.collection',
      'user.role.settings',
    ])) {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['entity.user.collection', []],
      ]);
    }

    // Reports.
    if (in_array($route_name, [
      'dblog.overview',
      'dblog.access_denied',
      'dblog.page_not_found',
      'dblog.search',
    ])) {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['system.admin_reports', []],
      ]);
    }

    // Configuration.
    if (in_array($route_name, [
      'system.admin_config',
      'devel.admin_settings',
    ])) {
      $link = $this->getLinkByRoutes($menu_name, [
            [$route_name, $route_params],
            ['system.admin_config', []],
      ]);
    }

+2 −2
Original line number Diff line number Diff line
@@ -6,9 +6,9 @@ use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Security\TrustedCallbackInterface;

/**
 * Class GinToolbar.
 * Adds active trail to trail.
 *
 * @package Drupal\gin_toolbar\Render\Element
 * * @package Drupal\gin_toolbar\Render\Element.
 */
class GinToolbar implements TrustedCallbackInterface {