How do I check if a user may access a given route? I am trying to render a link from a Url object and verify the user actually has access to that URL, like when viewing a node.

For some reason, this always returns FALSE, although the node is accessible when $language is the set language.

$_url = Url::fromRoute('&lt;current&gt;', [], ['language' =&gt; $language]);
if ($_url-&gt;access()) {
  // The code inside here is never executed.
}


How do I verify a user may access the given path, without actually loading the entity behind that path?



edit: current state:

$currentPath = \Drupal::service('path.current')-&gt;getPath();
$urlObject = Url::fromUserInput($currentPath);
$routeName = $urlObject-&gt;getRouteName();

$linkUrl = Url::fromRoute($routeName, [], ['language' =&gt; $dataLangId]);

debug($languageData['languageName']);
debug($linkUrl-&gt;toString());

if ($linkUrl-&gt;access()) {
  debug('access');
}
else {
  debug('denied');

}


results in:


  Some mandatory parameters are missing ("node") to generate a URL for route "entity.node.canonical
I don't know why 


$_url = Url::fromRoute('', [], ['language' => $language]);


Doesn't work with route name &lt;current&gt; but it works with other route names.
For example with route with name some_module.some_route_name the following 
will work. 



  $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
  $_url = Url::fromRoute('some_module.some_route_name', [], ['language' => $language]);
  $userCurrent = \Drupal::currentUser();
  if ($_url->access($userCurrent)) {
    //- Do Stuff
  }



In your case for the current route. Try this out.


use Drupal\Core\Url;

  $request = \Drupal::request();
  $_url = Url::createFromRequest($request);
  $userCurrent = \Drupal::currentUser();
   if ($_url->access($userCurrent)) {
     //- Do Stuff 
  }