Drupal 9 non-existent service "path.alias_manager" in to path_alias.manager

ISSUE:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "path.alias_manager". Did you mean this: "path_alias.manager"? in Drupal\Component\DependencyInjection\Container->get() (line 156 of core\lib\Drupal\Component\DependencyInjection\Container.php).

Drupal::service('path.alias_manager') (Line: 53)

 

Solution: 

Drupal 9

change path.alias_manager  in to path_alias.manager in D9, That's it.

$current_path = \Drupal::service('path.current')->getPath();
$result = \Drupal::service('path_alias.manager')->getAliasByPath($current_path);
Tags

Comments

Hi,
I'm new to drupal. Where (which file) do I have to change this parameter?

(change path.alias_manager in to path_alias.manager in D9, That's it.)

Thanks in advance

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
2 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Instagram Without API

Could not reach Instagram server