Drupal 8 Url常用

$current_path = \Drupal::service('path.current')->getPath();
$request = \Drupal::request();
$uri = $request->getUriForPath($current_path);

// 当前完成的路径,不包括query: http://localhost:88/drupal8/web/devel/php
dpm($uri);

// 只是后缀: /drupal8/web/devel/php?a=1&b=1
dpm($request->getRequestUri());


// 当前完整的路径,包括query: http://localhost:88/drupal8/web/devel/php?a=1&b=1
dpm($request->getUri());