saveOverride example

/** * {@inheritdoc} */
  public function updateLink(array $new_definition_values$persist) {
    // Filter the list of updates to only those that are allowed.     $overrides = array_intersect_key($new_definition_values$this->overrideAllowed);
    // Update the definition.     $this->pluginDefinition = $overrides + $this->getPluginDefinition();
    if ($persist) {
      // Always save the menu name as an override to avoid defaulting to tools.       $overrides['menu_name'] = $this->pluginDefinition['menu_name'];
      $this->staticOverride->saveOverride($this->getPluginId()$this->pluginDefinition);
    }
    return $this->pluginDefinition;
  }

}
->will($this->returnSelf());
    $config->expects($this->exactly(2))
      ->method('save');

    $config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
    $config_factory->expects($this->once())
      ->method('getEditable')
      ->willReturn($config);

    $static_override = new StaticMenuLinkOverrides($config_factory);

    $static_override->saveOverride('test1', ['parent' => 'test0']);
    $static_override->saveOverride('test1.la__ma', ['parent' => 'test1']);
  }

  /** * Tests the deleteOverride and deleteOverrides method. * * @param array|string $ids * Either a single ID or multiple ones as array. * @param array $old_definitions * The definitions before the deleting * @param array $new_definitions * The definitions after the deleting. * * @dataProvider providerTestDeleteOverrides */
'title' => 'Hey jude',
      'enabled' => 1,
      'expanded' => 1,
      'menu_name' => 'admin',
      'parent' => '',
      'weight' => 10,
    ];
    $expected_plugin_definition = $plugin_definition;
    $expected_plugin_definition['weight'] = -10;

    $static_override = $this->prophesize(StaticMenuLinkOverridesInterface::class);
    $static_override->saveOverride('example_menu_link', $expected_plugin_definition);
    $static_override = $static_override->reveal();

    $menu_link = new MenuLinkDefault([], 'example_menu_link', $plugin_definition$static_override);

    $this->assertEquals($expected_plugin_definition$menu_link->updateLink(['weight' => -10], TRUE));
  }

  /** * @covers ::updateLink */
  public function testUpdateLinkWithoutPersist() {
    
Home | Imprint | This part of the site doesn't use cookies.