Issue #1945418 by tim.plunkett, jaskho: Fixed New-style placeholders in menu_router() table break breadcrumbs, menu tree, etc.
parent
8aedb8ba85
commit
20ec5dc16d
|
@ -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 @@ class MenuRouterTest extends WebTestBase {
|
|||
$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.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
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'
|
Loading…
Reference in New Issue