Skip to main content
Category:

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 
}

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook