/**
  * @covers ::updateLink
  */
 public function testUpdateLinkWithoutPersist()
 {
     $plugin_definition = ['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()->shouldNotBeCalled();
     $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], FALSE));
 }
 /**
  * {@inheritdoc}
  */
 public function getOptions()
 {
     $options = parent::getOptions();
     // Append the current path as destination to the query string.
     $options['query']['destination'] = Url::fromRoute('<current>')->toString();
     return $options;
 }
Beispiel #3
0
 /**
  * Constructs a new LoginLogoutMenuLink.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Menu\StaticMenuLinkOverridesInterface $static_override
  *   The static override storage.
  * @param \Drupal\Core\Session\AccountInterface $current_user
  *   The current user.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, StaticMenuLinkOverridesInterface $static_override, AccountInterface $current_user)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $static_override);
     $this->currentUser = $current_user;
 }
 /**
  * {@inheritdoc}
  */
 public function getOptions()
 {
     $options = parent::getOptions();
     $options['query']['path'] = '/' . Url::fromRoute('<current>')->getInternalPath();
     return $options;
 }
 /**
  * Constructs the plugin object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Menu\StaticMenuLinkOverridesInterface $static_override
  *   The static override storage.
  * @param \Drupal\Core\Database\Connection $db_connection
  *   The database connection.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, StaticMenuLinkOverridesInterface $static_override, Connection $db_connection)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $static_override);
     $this->dbConnection = $db_connection;
 }