In each controller you make, there are special objects you can use to get data you may need. They are
$request
$route_match
for more on each of them check here
https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/using-parameters-in-routes#s-typehinted-parameters