how should I do if I need to show to a link menu based on a condition ?
This is my YML for my menu link :
double_vue_klesia.backuserswitch: title: 'Retour user précédent' menu_name: navigation-principale description: 'Switch back to your user account.' route_name: double_vue_klesia.backuser.switch weight: 1
I want to show this link only :
This is in PHP, but I need this to be on YML (unless there a way to intercept it in php and hide it ?).
If my isSwtichUser is true (from my service), I want to show the link. But I can find a way to do it.
I'm using this module : https://www.drupal.org/project/userswitch
I "just" need to display a link to go back to the original user (link accessible from my frontend)
AccessResult::forbidden()->setCacheMaxAge(0). But better find the correct caching data for the service, with cache max age = 0 you disable a lot of caching on your page, which is bad for performance. Btw. you need to add caching also in your latest edit for a normal link if it depends on a condition.