diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 17d8663..11ab4df 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -151,17 +151,16 @@ protected function getRoute($view_id, $display_id) { // routes (defined via {}). As a name for the parameter use arg_$key, so // it can be pulled in the views controller from the request. foreach ($bits as $pos => $bit) { - if ($bit == '%') { - // Generate the name of the parameter using the key of the argument - // handler. - $arg_id = 'arg_' . $arg_counter++; - $bits[$pos] = '{' . $arg_id . '}'; - $argument_map[$arg_id] = $arg_id; - } - elseif (strpos($bit, '%') === 0) { - // Use the name defined in the path. - $parameter_name = substr($bit, 1); + if (strpos($bit, '%') === 0) { + // Use the name defined in the path. If no name is given then default to + // the base entity type for this view. $arg_id = 'arg_' . $arg_counter++; + if ($bit !== '%') { + $parameter_name = substr($bit, 1); + } + else { + $parameter_name = !empty($this->view->getBaseEntityType()) ? $this->view->getBaseEntityType()->id() : $arg_id; + } $argument_map[$arg_id] = $parameter_name; $bits[$pos] = '{' . $parameter_name . '}'; } diff --git a/core/modules/views/src/Tests/Plugin/MenuLinkTest.php b/core/modules/views/src/Tests/Plugin/MenuLinkTest.php index 06e661f..cdc5972 100644 --- a/core/modules/views/src/Tests/Plugin/MenuLinkTest.php +++ b/core/modules/views/src/Tests/Plugin/MenuLinkTest.php @@ -43,6 +43,7 @@ protected function setUp() { $this->adminUser = $this->drupalCreateUser(['administer views', 'administer menu']); $this->drupalPlaceBlock('system_menu_block:main'); + $this->drupalPlaceBlock('local_tasks_block'); $this->drupalCreateContentType(['type' => 'page']); } @@ -93,6 +94,10 @@ public function testHierarchicalMenuLinkVisibility() { $this->drupalGet($node->urlInfo()); $this->assertText('Primary level node'); $this->assertText('Secondary level view page'); + + //Test that local task menu items with arguments work. + $this->drupalGet('node/' . $node->id() . '/local'); + $this->assertResponse(200); } } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_menu_link.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_menu_link.yml index d51b920..00d714e 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_menu_link.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_menu_link.yml @@ -6,7 +6,7 @@ label: '' module: views description: '' tag: '' -base_table: views_test_data +base_table: node_field_data base_field: nid core: '8' display: @@ -17,12 +17,53 @@ display: pager: false sorts: false fields: - age: - field: age - id: age + title: + id: title + table: node_field_data + field: title + entity_type: node + entity_field: title + label: '' + alter: + alter_text: false + make_link: false + absolute: false + trim: false + word_boundary: false + ellipsis: false + strip_tags: false + html: false + hide_empty: false + empty_zero: false + settings: + link_to_entity: true + plugin_id: field relationship: none - table: views_test_data - plugin_id: numeric + group_type: group + admin_label: '' + exclude: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_alter_empty: true + click_sort_column: value + type: string + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false display_plugin: default display_title: Master id: default @@ -35,4 +76,60 @@ display: display_options: display_extenders: { } path: test-menu-link - + page_2: + display_options: + defaults: + arguments: false + title: false + arguments: + nid: + id: nid + table: node + field: nid + relationship: none + group_type: group + admin_label: '' + default_action: ignore + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: fixed + default_argument_options: + argument: '' + default_argument_skip_url: false + summary_options: + base_path: '' + count: true + items_per_page: 25 + override: false + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + break_phrase: false + not: false + entity_type: node + entity_field: nid + plugin_id: numeric + menu: + type: tab + title: 'Test local tab' + description: '' + menu_name: tools + parent: '' + weight: 0 + context: '0' + path: node/%/local + title: 'Test local page' + display_plugin: page + display_title: Page + id: page_2 + position: 0