New!
Import instagram posts as nodes automatically with the instagram importer module for drupal 8 & 9.

 

May 11, 2020 in Drupal 8

The routing system that drupal 8 offers is flexible in terms of validation. It is possible to validate your route against some typical regex lines. 

In the following mymodule.routing.yml yaml file, the {id} url parameter will be matched against the '\d+' regex, meaning a numeric character

/path/test/1 will be valid
/path/test/test will be 'page not found'

mymodule.controller:
  path: '/path/{method}/{id}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\mymoduleSaveController::Render'
    _title_callback: '\Drupal\mymodule\Controller\mymoduleSaveController::getTitle'
  requirements:
    _access: 'TRUE'
    id: '\d+'