Skip to content
Snippets Groups Projects
Commit 20ec5dc1 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1945418 by tim.plunkett, jaskho: Fixed New-style placeholders in...

Issue #1945418 by tim.plunkett, jaskho: Fixed New-style placeholders in menu_router() table break breadcrumbs, menu tree, etc.
parent 8aedb8ba
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -2701,6 +2701,8 @@ function _menu_router_merge_route(array $router_item, $path) {
$router_item['page callback'] = 'USES_ROUTE';
$router_item['access callback'] = TRUE;
// Translate placeholders, e.g. {foo} -> %.
$router_item['path'] = preg_replace('/{' . DRUPAL_PHP_FUNCTION_PATTERN . '}/', '%', $router_item['path']);
return $router_item;
}
......
......@@ -68,6 +68,23 @@ function setUp() {
$this->drupalPlaceBlock('system_menu_block:menu-tools');
}
/**
* Test local tasks with route placeholders.
*/
public function testHookMenuIntegration() {
// Generate base path with random argument.
$base_path = 'foo/' . $this->randomName(8);
$this->drupalGet($base_path);
// Confirm correct controller activated.
$this->assertText('test1');
// Confirm local task links are displayed.
$this->assertLink('Local task A');
$this->assertLink('Local task B');
// Confirm correct local task href.
$this->assertLinkByHref(url($base_path));
$this->assertLinkByHref(url($base_path . '/b'));
}
/**
* Test title callback set to FALSE.
*/
......
<?php
/**
* @file
* Contains \Drupal\menu_test\TestControllers.
*/
namespace Drupal\menu_test;
use Drupal\Core\Entity\EntityInterface;
/**
* Controllers for testing the menu integration routing system.
*/
class TestControllers {
/**
* Prints out test data.
*/
public function test1() {
return 'test1';
}
/**
* Prints out test data.
*/
public function test2() {
return 'test2';
}
}
......@@ -394,6 +394,23 @@ function menu_test_menu() {
'access callback' => TRUE,
);
// Parent page for controller-based local tasks.
$items['foo/%'] = array(
'title' => 'Controller-based local tasks',
'route_name' => 'menu_router_test1',
);
// Controller-based local task.
$items['foo/%/a'] = array(
'title' => 'Local task A',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
// Controller-based local task.
$items['foo/%/b'] = array(
'title' => 'Local task B',
'route_name' => 'menu_router_test3',
'type' => MENU_LOCAL_TASK,
);
return $items;
}
......
menu_router_test1:
pattern: '/foo/{bar}'
defaults:
_content: '\Drupal\menu_test\TestControllers::test1'
requirements:
_access: 'TRUE'
menu_router_test3:
pattern: '/foo/{bar}/b'
defaults:
_content: '\Drupal\menu_test\TestControllers::test2'
requirements:
_access: 'TRUE'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment