Issue #2892942 by Wim Leers, Chi, tedbow: Contextual links support options but not use them to generate links
(cherry picked from commit 4c8c5e1f0f)
			
			
				8.5.x
			
			
		
							parent
							
								
									36ee6b39da
								
							
						
					
					
						commit
						279b57d1ad
					
				| 
						 | 
				
			
			@ -78,7 +78,7 @@ class ContextualLinks extends RenderElement {
 | 
			
		|||
      $class = Html::getClass($class);
 | 
			
		||||
      $links[$class] = [
 | 
			
		||||
        'title' => $item['title'],
 | 
			
		||||
        'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : []),
 | 
			
		||||
        'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : [], $item['localized_options']),
 | 
			
		||||
      ];
 | 
			
		||||
    }
 | 
			
		||||
    $element['#links'] = $links;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,7 +137,7 @@ class ContextualDynamicContextTest extends WebTestBase {
 | 
			
		|||
    // Get a page where contextual links are directly rendered.
 | 
			
		||||
    $this->drupalGet(Url::fromRoute('menu_test.contextual_test'));
 | 
			
		||||
    $this->assertEscaped("<script>alert('Welcome to the jungle!')</script>");
 | 
			
		||||
    $this->assertLink('Edit menu - contextual');
 | 
			
		||||
    $this->assertRaw('<li class="menu-testcontextual-hidden-manage-edit"><a href="' . base_path() . 'menu-test-contextual/1/edit" class="use-ajax" data-dialog-type="modal" data-is-something>Edit menu - contextual</a></li>');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,11 @@ menu_test.contextual_hidden_manage_edit:
 | 
			
		|||
  title: 'Edit menu - contextual'
 | 
			
		||||
  group: menu_test_menu
 | 
			
		||||
  route_name: menu_test.contextual_hidden_manage_edit
 | 
			
		||||
  options:
 | 
			
		||||
    attributes:
 | 
			
		||||
      class: ['use-ajax']
 | 
			
		||||
      data-dialog-type: 'modal'
 | 
			
		||||
      data-is-something: TRUE
 | 
			
		||||
 | 
			
		||||
menu_test.hidden_block_configure:
 | 
			
		||||
  title: 'Configure block'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -278,20 +278,7 @@ class ContextualLinkManagerTest extends UnitTestCase {
 | 
			
		|||
    // Set up mocking of the plugin factory.
 | 
			
		||||
    $map = [];
 | 
			
		||||
    foreach ($definitions as $plugin_id => $definition) {
 | 
			
		||||
      $plugin = $this->getMock('Drupal\Core\Menu\ContextualLinkInterface');
 | 
			
		||||
      $plugin->expects($this->any())
 | 
			
		||||
        ->method('getRouteName')
 | 
			
		||||
        ->will($this->returnValue($definition['route_name']));
 | 
			
		||||
      $plugin->expects($this->any())
 | 
			
		||||
        ->method('getTitle')
 | 
			
		||||
        ->will($this->returnValue($definition['title']));
 | 
			
		||||
      $plugin->expects($this->any())
 | 
			
		||||
        ->method('getWeight')
 | 
			
		||||
        ->will($this->returnValue($definition['weight']));
 | 
			
		||||
      $plugin->expects($this->any())
 | 
			
		||||
        ->method('getOptions')
 | 
			
		||||
        ->will($this->returnValue($definition['options']));
 | 
			
		||||
      $map[] = [$plugin_id, [], $plugin];
 | 
			
		||||
      $map[] = [$plugin_id, [], new ContextualLinkDefault([], $plugin_id, $definition)];
 | 
			
		||||
    }
 | 
			
		||||
    $this->factory->expects($this->any())
 | 
			
		||||
      ->method('createInstance')
 | 
			
		||||
| 
						 | 
				
			
			@ -308,6 +295,7 @@ class ContextualLinkManagerTest extends UnitTestCase {
 | 
			
		|||
      $this->assertEquals($definition['weight'], $result[$plugin_id]['weight']);
 | 
			
		||||
      $this->assertEquals($definition['title'], $result[$plugin_id]['title']);
 | 
			
		||||
      $this->assertEquals($definition['route_name'], $result[$plugin_id]['route_name']);
 | 
			
		||||
      $this->assertEquals($definition['options'], $result[$plugin_id]['localized_options']);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue