When I save a menu link pointing to a node (nid 5, alias /woohoo/magic/test, it's value in the database is: entity:node/5

I'm trying to convert fully formed user inputs such as "" to the path stored in menu in the databse.

I've tried the following:

$local_path = url::fromUserInput($possibly_local_path);

// $local_path->getRouteName() returns "entity.node.canonical"
// $local_path->toString() returns "/woohoo/magic/test"
// $local_path->getInternalPath() returns "node/5"

Please note I can't just do string concatenations. I don't always know that the path is to an entity, such as when I am using group module group content entities.

Any ideas?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.