Commit cd74c624 authored by webchick's avatar webchick

Issue #2091691 by tim.plunkett: Convert test non-form page callbacks to routes and controllers.

parent 2867e5ba
This diff is collapsed.
......@@ -84,7 +84,9 @@ public function content(Request $request, $_content) {
}
if (!is_array($page_content)) {
$page_content = array(
'#markup' => $page_content,
'main' => array(
'#markup' => $page_content,
),
);
}
if (!isset($page_content['#title'])) {
......
......@@ -30,8 +30,8 @@ function custom_block_help($path, $arg) {
/**
* Implements hook_menu_local_tasks().
*/
function custom_block_menu_local_tasks(&$data, $router_item, $root_path) {
if ($router_item['route_name'] == 'custom_block.list') {
function custom_block_menu_local_tasks(&$data, $route_name) {
if ($route_name == 'custom_block.list') {
// @todo Move to a LocalAction plugin when https://drupal.org/node/2045267
// allows local actions to work with query strings.
$item = menu_get_item('block/add');
......@@ -48,13 +48,13 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) {
$routes = array_map(function ($theme) {
return "block.admin_display_$theme";
}, array_keys(list_themes()));
if (in_array($router_item['route_name'], $routes)) {
if (in_array($route_name, $routes)) {
// @todo Move to a LocalAction plugin when https://drupal.org/node/2045267
// allows local actions to work with query strings.
$item = menu_get_item('block/add');
if ($item['access']) {
// Add a destination parameter.
$item['localized_options']['query']['theme'] = end($router_item['map']);
$item['localized_options']['query']['theme'] = \Drupal::request()->attributes->get('theme');
$data['actions']['block/add'] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
......
......@@ -92,10 +92,7 @@ function custom_block_test_menu() {
$items['custom-block/%custom_block'] = array(
'title callback' => 'entity_page_label',
'title arguments' => array(1),
'page callback' => 'entity_view',
'page arguments' => array(1, 'default'),
'access callback' => 'entity_page_access',
'access arguments' => array(1, 'view'),
'route_name' => 'custom_block_test.custom_block_view',
);
return $items;
}
custom_block_test.custom_block_view:
path: '/custom-block/{custom_block}'
defaults:
_entity_view: 'custom_block'
requirements:
_entity_access: 'custom_block.view'
......@@ -372,7 +372,7 @@ function testCommentFunctionality() {
$data = array('bundle' => 'entity_test_render', 'name' => $random_label);
$new_entity = entity_create('entity_test_render', $data);
$new_entity->save();
$this->drupalGet('entity_test_render/manage/' . $new_entity->id() . '/edit');
$this->drupalGet('entity_test_render/manage/' . $new_entity->id());
$this->assertNoFieldChecked('edit-field-foobar-0-status-1');
$this->assertFieldChecked('edit-field-foobar-0-status-2');
$this->assertNoField('edit-field-foobar-0-status-0');
......
content_translation.local_tasks:
derivative: 'Drupal\content_translation\Plugin\Derivative\ContentTranslationLocalTasks'
class: 'Drupal\content_translation\Plugin\ContentTranslationLocalTasks'
weight: 100
<?php
/**
* @file
* Contains \Drupal\content_translation\Plugin\ContentTranslationLocalTasks.
*/
namespace Drupal\content_translation\Plugin;
use Drupal\Core\Menu\LocalTaskDefault;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides route parameter manipulation for content translation local tasks.
*/
class ContentTranslationLocalTasks extends LocalTaskDefault {
/**
* {@inheritdoc}
*/
public function getRouteParameters(Request $request) {
$parameters = parent::getRouteParameters($request);
$entity_type = $this->pluginDefinition['entity_type'];
if ($raw_variables = $request->attributes->get('_raw_variables')) {
// When the entity type is in the path, populate 'entity' for any dynamic
// local tasks.
if ($raw_variables->has($entity_type)) {
$entity = $raw_variables->get($entity_type);
$parameters['entity'] = $entity;
}
// When 'entity' is in the path, populate the parameters with the value
// for the actual entity type.
elseif ($raw_variables->has('entity')) {
$entity = $raw_variables->get('entity');
$parameters[$entity_type] = $entity;
}
}
return $parameters;
}
}
<?php
/**
* @file
* Contains \Drupal\content_translation\Plugin\Derivative\ContentTranslationLocalTasks.
*/
namespace Drupal\content_translation\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DerivativeBase;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface;
use Drupal\Core\Routing\RouteProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides dynamic local tasks for content translation.
*/
class ContentTranslationLocalTasks extends DerivativeBase implements ContainerDerivativeInterface {
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManager
*/
protected $entityManager;
/**
* The route provider.
*
* @var \Drupal\Core\Routing\RouteProviderInterface
*/
protected $routeProvider;
/**
* Constructs a new ContentTranslationLocalTasks.
*
* @param \Drupal\Core\Entity\EntityManager $entity_manager
* The entity manager.
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* The route provider.
*/
public function __construct(EntityManager $entity_manager, RouteProviderInterface $route_provider) {
$this->entityManager = $entity_manager;
$this->routeProvider = $route_provider;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static(
$container->get('entity.manager'),
$container->get('router.route_provider')
);
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions(array $base_plugin_definition) {
// Create tabs for all possible entity types.
foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) {
if ($entity_info['translatable'] && isset($entity_info['translation'])) {
$path = '/' . preg_replace('/%(.*)/', '{$1}', $entity_info['menu_base_path']);
if ($routes = $this->routeProvider->getRoutesByPattern($path)->all()) {
// Find the route name for the entity page.
$entity_route_name = key($routes);
$entity_tab = $entity_route_name . '_tab';
// Find the route name for the translation overview.
$translation_route_name = "content_translation.translation_overview_$entity_type";
$translation_tab = $translation_route_name . '_tab';
// Both tabs will have the same root and entity type.
$common_tab_settings = array(
'tab_root_id' => $entity_tab,
'entity_type' => $entity_type,
);
$this->derivatives[$entity_tab] = $base_plugin_definition + $common_tab_settings;
$this->derivatives[$entity_tab]['title'] = t('Edit');
$this->derivatives[$entity_tab]['route_name'] = $entity_route_name;
$this->derivatives[$translation_tab] = $base_plugin_definition + $common_tab_settings;
$this->derivatives[$translation_tab]['title'] = t('Translate');
$this->derivatives[$translation_tab]['route_name'] = $translation_route_name;
}
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
......@@ -112,7 +112,7 @@ function testDateField() {
"{$field_name}[0][value][date]" => $date->format($date_format),
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
$this->assertRaw($date->format($date_format));
......@@ -183,7 +183,7 @@ function testDatetimeField() {
"{$field_name}[0][value][time]" => $date->format($time_format),
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
$this->assertRaw($date->format($date_format));
......@@ -276,7 +276,7 @@ function testDatelistWidget() {
}
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
......
......@@ -103,7 +103,7 @@ function testEmailField() {
"{$field_name}[0][value]" => $value,
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
$this->assertRaw($value);
......
......@@ -129,14 +129,14 @@ function testFieldFormSingle() {
"{$field_name}[0][value]" => $value,
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
$entity = entity_load('entity_test', $id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was saved');
// Display edit form.
$this->drupalGet('entity_test/manage/' . $id . '/edit');
$this->drupalGet('entity_test/manage/' . $id);
$this->assertFieldByName("{$field_name}[0][value]", $value, 'Widget is displayed with the correct default value');
$this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
......@@ -160,7 +160,7 @@ function testFieldFormSingle() {
'name' => $this->randomName(),
"{$field_name}[0][value]" => $value
);
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
$this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save'));
$this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated');
$this->container->get('entity.manager')->getStorageController('entity_test')->resetCache(array($id));
$entity = entity_load('entity_test', $id);
......@@ -194,7 +194,7 @@ function testFieldFormDefaultValue() {
"{$field_name}[0][value]" => '',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created.');
$entity = entity_load('entity_test', $id);
......@@ -225,7 +225,7 @@ function testFieldFormSingleRequired() {
"{$field_name}[0][value]" => $value,
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
$entity = entity_load('entity_test', $id);
......@@ -238,7 +238,7 @@ function testFieldFormSingleRequired() {
'name' => $this->randomName(),
"{$field_name}[0][value]" => $value,
);
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
$this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save'));
$this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation');
}
......@@ -315,7 +315,7 @@ function testFieldFormUnlimited() {
// Submit the form and create the entity.
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
$entity = entity_load('entity_test', $id);
......@@ -467,7 +467,7 @@ function testFieldFormMultipleWidget() {
$field_name => '1, 2, 3',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
// Check that the values were saved.
......@@ -475,7 +475,7 @@ function testFieldFormMultipleWidget() {
$this->assertFieldValues($entity_init, $field_name, array(1, 2, 3));
// Display the form, check that the values are correctly filled in.
$this->drupalGet('entity_test/manage/' . $id . '/edit');
$this->drupalGet('entity_test/manage/' . $id);
$this->assertFieldByName($field_name, '1, 2, 3', 'Widget is displayed.');
// Submit the form with more values than the field accepts.
......@@ -548,7 +548,7 @@ function testFieldFormAccess() {
"{$field_name}[0][value]" => 1,
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match("|$entity_type/manage/(\d+)/edit|", $this->url, $match);
preg_match("|$entity_type/manage/(\d+)|", $this->url, $match);
$id = $match[1];
// Check that the default value was saved.
......@@ -563,7 +563,7 @@ function testFieldFormAccess() {
"{$field_name}[0][value]" => 2,
'revision' => TRUE,
);
$this->drupalPostForm($entity_type . '/manage/' . $id . '/edit', $edit, t('Save'));
$this->drupalPostForm($entity_type . '/manage/' . $id, $edit, t('Save'));
// Check that the new revision has the expected values.
$this->container->get('entity.manager')->getStorageController($entity_type)->resetCache(array($id));
......@@ -605,7 +605,7 @@ function testFieldFormHiddenWidget() {
// the field that uses the hidden widget.
$this->assertNoField("{$field_name}[0][value]", 'The hidden widget is not displayed');
$this->drupalPostForm(NULL, array('user_id' => 1, 'name' => $this->randomName()), t('Save'));
preg_match('|' . $entity_type . '/manage/(\d+)/edit|', $this->url, $match);
preg_match('|' . $entity_type . '/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test_rev @id has been created.', array('@id' => $id)), 'Entity was created');
$entity = entity_load($entity_type, $id);
......@@ -622,7 +622,7 @@ function testFieldFormHiddenWidget() {
->save();
// Display edit form.
$this->drupalGet($entity_type . '/manage/' . $id . '/edit');
$this->drupalGet($entity_type . '/manage/' . $id);
$this->assertFieldByName("{$field_name}[0][value]", 99, 'Widget is displayed with the correct default value');
// Update the entity.
......@@ -643,7 +643,7 @@ function testFieldFormHiddenWidget() {
// Create a new revision.
$edit = array('revision' => TRUE);
$this->drupalPostForm($entity_type . '/manage/' . $id . '/edit', $edit, t('Save'));
$this->drupalPostForm($entity_type . '/manage/' . $id, $edit, t('Save'));
// Check that the expected value has been carried over to the new revision.
entity_get_controller($entity_type)->resetCache(array($id));
......
......@@ -122,7 +122,7 @@ function testFieldFormTranslationRevisions() {
"{$field_name}[0][value]" => $entity->{$field_name}->value,
'revision' => TRUE,
);
$this->drupalPostForm($this->entity_type . '/manage/' . $entity->id() . '/edit', $edit, t('Save'));
$this->drupalPostForm($this->entity_type . '/manage/' . $entity->id(), $edit, t('Save'));
// Check translation revisions.
$this->checkTranslationRevisions($entity->id(), $entity->getRevisionId(), $available_langcodes);
......
......@@ -148,11 +148,11 @@ function forum_menu() {
/**
* Implements hook_menu_local_tasks().
*/
function forum_menu_local_tasks(&$data, $router_item, $root_path) {
function forum_menu_local_tasks(&$data, $route_name) {
global $user;
// Add action link to 'node/add/forum' on 'forum' sub-pages.
if ($root_path == 'forum' || $root_path == 'forum/%') {
if (in_array($route_name, array('forum.index', 'forum.page'))) {
$request = \Drupal::request();
$forum_term = $request->attributes->get('taxonomy_term');
$vid = \Drupal::config('forum.settings')->get('vocabulary');
......
......@@ -107,7 +107,7 @@ function testURLValidation() {
"{$field_name}[0][url]" => $value,
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
$this->assertRaw($value);
......@@ -228,7 +228,7 @@ function testLinkTitle() {
"{$field_name}[0][title]" => '',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
......@@ -243,7 +243,7 @@ function testLinkTitle() {
'name' => $this->randomName(),
"{$field_name}[0][title]" => $title,
);
$this->drupalPostForm("entity_test/manage/$id/edit", $edit, t('Save'));
$this->drupalPostForm("entity_test/manage/$id", $edit, t('Save'));
$this->assertText(t('entity_test @id has been updated.', array('@id' => $id)));
$this->renderTestEntity($id);
......@@ -309,7 +309,7 @@ function testLinkFormatter() {
// Assert label is shown.
$this->assertText('Read more about this entity');
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
......@@ -445,7 +445,7 @@ function testLinkSeparateFormatter() {
"{$field_name}[1][title]" => $title2,
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
......
......@@ -1062,9 +1062,10 @@ function node_menu() {
/**
* Implements hook_menu_local_tasks().
*/
function node_menu_local_tasks(&$data, $router_item, $root_path) {
function node_menu_local_tasks(&$data, $route_name) {
// Add action link to 'node/add' on 'admin/content' page.
if ($root_path == 'admin/content') {
// @todo Switch to inspecting route name in https://drupal.org/node/2021161.
if (current_path() == 'admin/content') {
$item = menu_get_item('node/add');
if ($item['access']) {
$data['actions'][] = array(
......
......@@ -104,7 +104,7 @@ function testNumberDecimalField() {
"{$this->field['field_name']}[0][value]" => $value,
);
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)/edit|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
$this->assertRaw(round($value, 2), 'Value is displayed.');
......
......@@ -31,7 +31,7 @@ function testSelectListDynamic() {
$this->drupalLogin($web_user);
// Display form.
$this->drupalGet('entity_test_rev/manage/' . $this->entity->id() . '/edit');
$this->drupalGet('entity_test_rev/manage/' . $this->entity->id());
$options = $this->xpath('//select[@id="edit-test-options"]/option');
$this->assertEqual(count($options), count($this->test) + 1);
foreach ($options as $option) {
......
......@@ -77,14 +77,14 @@ protected function assertFormCRUD($entity_type) {
$this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $entity_type)));
$edit['name'] = $name2;
$this->drupalPostForm($entity_type . '/manage/' . $entity->id() . '/edit', $edit, t('Save'));
$this->drupalPostForm($entity_type . '/manage/' . $entity->id(), $edit, t('Save'));
$entity = $this->loadEntityByName($entity_type, $name1);
$this->assertFalse($entity, format_string('%entity_type: The entity has been modified.', array('%entity_type' => $entity_type)));
$entity = $this->loadEntityByName($entity_type, $name2);
$this->assertTrue($entity, format_string('%entity_type: Modified entity found in the database.', array('%entity_type' => $entity_type)));
$this->assertNotEqual($entity->name->value, $name1, format_string('%entity_type: The entity name has been modified.', array('%entity_type' => $entity_type)));
$this->drupalPostForm($entity_type . '/manage/' . $entity->id() . '/edit', array(), t('Delete'));
$this->drupalPostForm($entity_type . '/manage/' . $entity->id(), array(), t('Delete'));
$entity = $this->loadEntityByName($entity_type, $name2);
$this->assertFalse($entity, format_string('%entity_type: Entity not found in the database.', array('%entity_type' => $entity_type)));
}
......
......@@ -554,57 +554,6 @@ protected function menuLoadRouter($router_path) {
return db_query('SELECT * FROM {menu_router} WHERE path = :path', array(':path' => $router_path))->fetchAssoc();
}
/**
* Tests inheritance of 'load arguments'.
*/
function testMenuLoadArgumentsInheritance() {
$expected = array(
'menu-test/arguments/%/%' => array(
2 => array('menu_test_argument_load' => array(3)),
3 => NULL,
),
// Arguments are inherited to normal children.
'menu-test/arguments/%/%/default' => array(
2 => array('menu_test_argument_load' => array(3)),
3 => NULL,
),
// Arguments are inherited to tab children.
'menu-test/arguments/%/%/task' => array(
2 => array('menu_test_argument_load' => array(3)),
3 => NULL,
),
// Arguments are only inherited to the same loader functions.
'menu-test/arguments/%/%/common-loader' => array(
2 => array('menu_test_argument_load' => array(3)),
3 => 'menu_test_other_argument_load',
),
// Arguments are not inherited to children not using the same loader
// function.
'menu-test/arguments/%/%/different-loaders-1' => array(
2 => NULL,
3 => 'menu_test_argument_load',
),
'menu-test/arguments/%/%/different-loaders-2' => array(
2 => 'menu_test_other_argument_load',
3 => NULL,
),
'menu-test/arguments/%/%/different-loaders-3' => array(
2 => NULL,
3 => NULL,
),
// Explicit loader arguments should not be overriden by parent.
'menu-test/arguments/%/%/explicit-arguments' => array(
2 => array('menu_test_argument_load' => array()),
3 => NULL,
),
);
foreach ($expected as $router_path => $load_functions) {
$router_item = $this->menuLoadRouter($router_path);
$this->assertIdentical(unserialize($router_item['load_functions']), $load_functions, format_string('Expected load functions for router %router_path' , array('%router_path' => $router_path)));
}
}
/**
* Test menu links that have optional placeholders.
*/
......
......@@ -136,19 +136,6 @@ function testModuleInvokeAll() {
$this->assertText('success!', 'module_invoke_all() dynamically loads a hook defined in hook_hook_info().');
}
/**
* Test that a menu item load function can invoke hooks defined in hook_hook_info().
*
* We test this separately from testModuleInvokeAll(), because menu item load
* functions execute early in the request handling.
*/
function testModuleInvokeAllDuringLoadFunction() {
\Drupal::moduleHandler()->install(array('module_test'), FALSE);
$this->resetAll();
$this->drupalGet('module-test/hook-dynamic-loading-invoke-all-during-load/module_test');
$this->assertText('success!', 'Menu item load function invokes a hook defined in hook_hook_info().');
}
/**
* Test dependency resolution.
*/
......
......@@ -858,12 +858,10 @@ function hook_menu_alter(&$items) {
* associative array as described above.
* - tabs: A list of (up to 2) tab levels that contain a list of of tabs keyed
* by their href, each one being an associative array as described above.
* @param array $router_item
* The menu system router item of the page.
* @param string $root_path
* The path to the root item for this set of tabs.
* @param string $route_name
* The route name of the page.
*/
function hook_menu_local_tasks(&$data, $router_item, $root_path) {
function hook_menu_local_tasks(&$data, $route_name) {
// Add an action linking to node/add to all pages.
$data['actions']['node/add'] = array(
'#theme' => 'menu_local_action',
......@@ -890,8 +888,6 @@ function hook_menu_local_tasks(&$data, $router_item, $root_path) {
),
),
),
// Define whether this link is active. This can usually be omitted.
'#active' => ($router_item['path'] == $root_path),
);
}
......@@ -904,14 +900,12 @@ function hook_menu_local_tasks(&$data, $router_item, $root_path) {
* @param array $data
* An associative array containing tabs and actions. See
* hook_menu_local_tasks() for details.
* @param array $router_item
* The menu system router item of the page.
* @param string $root_path
* The path to the root item for this set of tabs.
* @param string $route_name
* The route name of the page.
*
* @see hook_menu_local_tasks()
*/
function hook_menu_local_tasks_alter(&$data, $router_item, $root_path) {
function hook_menu_local_tasks_alter(&$data, $route_name) {
}
/**
......