if ($url->
isExternal()) { $generated_link =
new GeneratedLink();
$attributes['href'
] =
$url->
toString(FALSE
);
return $this->
doGenerate($generated_link,
$attributes,
$variables);
} if ($url->
isRouted() &&
$url->
getRouteName() === '<nolink>'
) { $generated_link =
new GeneratedNoLink();
unset($attributes['href'
],
$attributes['hreflang'
]);
return $this->
doGenerate($generated_link,
$attributes,
$variables);
} if ($url->
isRouted() &&
$url->
getRouteName() === '<button>'
) { $generated_link =
new GeneratedButton();
$attributes['type'
] = 'button';
unset($attributes['href'
],
$attributes['hreflang'
]);
return $this->
doGenerate($generated_link,
$attributes,
$variables);
} $generated_url =
$url->
toString(TRUE
);
$generated_link = GeneratedLink::
createFromObject($generated_url);
// The result of the URL generator is a plain-text URL to use as the href
// attribute, and it is escaped by \Drupal\Core\Template\Attribute.
$attributes['href'
] =
$generated_url->
getGeneratedUrl();
return $this->
doGenerate($generated_link,
$attributes,
$variables);
}