Drupal 8 – add menu item that include current user ID in path

Hi,

I am trying to achieve the followings:
1. for admin – to be able to view user reviews by accessing the url in format /user/XXX/reviews where XXX is user ID
2. to add menu item for each user with path /user/XXX/reviews where XXX is user logged in user ID

The first point is achieved by the following definition in mymodule.routing.yml

mymodule.user_reviews:
  path: user/{user_id}reviews
  defaults:
    _controller: 'DrupalmymoduleControllerUserReviewsController::reviews'
    _title: 'Reviews'
  requirements:
    _user_is_logged_in: 'TRUE'
    user_id: d+

I have a problem to add a menu item using the following code in mymodule.links.menu.yml

mymodule.user_reviews:
  title: 'My Reviews'
  weight: 10 
  description: 'User reviews'
  route_name: mymodule.user_reviews
  parent: 'account'

I am receiving the error “Some mandatory parameters are missing (“user_id”) to generate a URL for route “mymodule.user_reviews”

How can I pass current user id to menu item?

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed