You are here

public function MenuLinkField::getUrlObject in Menu Link (Field) 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Menu/MenuLinkField.php \Drupal\menu_link\Plugin\Menu\MenuLinkField::getUrlObject()

Returns a URL object containing either the external path or route.

Parameters

bool $title_attribute: (optional) If TRUE, add the link description as the title attribute if the description is not empty.

Return value

\Drupal\Core\Url A URL object containing either the external path or route.

Overrides MenuLinkBase::getUrlObject

File

src/Plugin/Menu/MenuLinkField.php, line 92

Class

MenuLinkField
Provides a menu link plugin for field-based menu links.

Namespace

Drupal\menu_link\Plugin\Menu

Code

public function getUrlObject($title_attribute = TRUE) {
  $options = $this
    ->getOptions();
  if ($title_attribute && ($description = $this
    ->getDescription())) {
    $options['attributes']['title'] = $description;
  }
  return $this
    ->getEntity()
    ->toUrl('canonical', $options);
}