Pass argument to custom access callback Is there a way to specify an argument to pass to a custom access callback, specifically an argument that isn't part of the path? Like in Drupal 7 you could do this:

function mymodule_menu() {
  $items['abc/$val'] = array(
    'page callback' =&gt; 'mymodule_abc_view',
    'access callback' =&gt; 'mymodule_abcdef_access',
    'access arguments' =&gt; array(1, 'test1'),
  );
  $items['def/$val'] = array(
    'page callback' =&gt; 'mymodule_def_view',
    'access callback' =&gt; 'mymodule_abcdef_access',
    'access arguments' =&gt; array(1, 'test2'),
  );
  return $items;
}

function mymodule_abc_access($val, $type) {
  return ($val['some_prop'] == $type);
}


So in Drupal 8 I would have this in mymodule.routing.yml:

mymodule.abc:
  path: 'abc/{val}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyModuleController::abc'
  requirements:
    _custom_access: '\Drupal\mymodule\Controller\MyModuleController::abcDefAccess'

mymodule.def:
  path: 'def/{val}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyModuleController::def'
  requirements:
    _custom_access: '\Drupal\mymodule\Controller\MyModuleController::abcDefAccess'


And in MyModuleController:

public function abcDefAccess($val, $type) {
  return AccessResult::allowedIf($val-&gt;someProp == $type);
}


But is there any way to pass 'test1' or 'test2' as $type? Otherwise I guess I would just have to make a separate access function for each type.
Your route:

regportal_user.orders:
  path: '/user/{user}/orders'
  defaults:
    _entity_view: 'user.orders'
    _title: 'Управление заказами'
  requirements:
    _custom_access: '\Drupal\regportal_user\Controller\RegportalUserController::accessOwnOrders'


Your controller:

  /**
   * Checks access for a regportal_user.orders route.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   *
   * @return \Drupal\Core\Access\AccessResult
   */
  public function accessOwnOrders(AccountInterface $account, $user) {
    if ($account-&gt;id() == $user) {
      return AccessResult::allowed();
    }

    return AccessResult::forbidden();
  }