RouteDetailMenuLink.php

Same filename in other branches
  1. 4.x src/Plugin/Menu/RouteDetailMenuLink.php
  2. 5.x src/Plugin/Menu/RouteDetailMenuLink.php

Namespace

Drupal\devel\Plugin\Menu

File

src/Plugin/Menu/RouteDetailMenuLink.php

View source
<?php

namespace Drupal\devel\Plugin\Menu;

use Drupal\Core\Menu\MenuLinkDefault;
use Drupal\Core\Url;

/**
 * Modifies the menu link to add current route path.
 */
class RouteDetailMenuLink extends MenuLinkDefault {
    
    /**
     * {@inheritdoc}
     */
    public function getOptions() {
        $options = parent::getOptions();
        $options['query']['path'] = '/' . Url::fromRoute('<current>')->getInternalPath();
        return $options;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheMaxAge() {
        return 0;
    }

}

Classes

Title Deprecated Summary
RouteDetailMenuLink Modifies the menu link to add current route path.