In order to support a consistent and comprehensible API for module developers to create links using the Drupal 8.0.x routing API, code that was forward-ported from Drupal 7 has been retired, the use of route name and parameters required in almost all cases and "system path" is not supported except as a temporary value entered into forms by end users that is converted during save.
This change introduces 2 new static factory methods on the
Url::fromRoute($route_name, $route_parameters, $options) Url::fromUri($uri, $options)
See api page Url::fromUri() for documentation of arguments.
This change also changes \Drupal\Core\Utility\LinkGenerator so that there is a single generate() method that accepts a Url value object, instead of having multiple methods to generate a link.
_l() are deprecated and *will* be removed before 8.0.0 is released.
// Internal path. $internal_link = l(t('Book admin'), 'admin/structure/book'); // External Uri. $external_link = l(t('External link'), 'http://www.example.com/', array('external' => TRUE));
// Internal path (defined by a route in Drupal 8). use Drupal\Core\Url; $url = Url::fromRoute('book.admin'); $internal_link = \Drupal::l(t('Book admin'), $url); // External Uri. use Drupal\Core\Url; $url = Url::fromUri('http://www.example.com/'); $external_link = \Drupal::l(t('External link'), $url);