All keys under the defaults
section which do not start with an underscore will be passed in as arguments to the controller. Name your arguments appropriately for the arguments of the controller. For example a mymodule.routing.yml file with the following:
mymodule.content:
path: '/mymodule'
defaults:
_controller: '\Drupal\mymodule\Controller\MyModuleController::content'
uid: 1
requirements:
_permission: 'access content'
Will pass on $uid
to the controller, so your content method can take $uid
:
// ...
public function content($uid) {
// Now you can use $uid
}