4

How can I pass the complete path arguments to a route defined in a mymodule.routing.yml file?

example_archive.content_archiv:
  path: '/examplearchiv/{myvalue}'
  defaults:
  _controller: '\Drupal\example_archiv\Controller\exampleArchiveController::content_archiv'
   _title: 'example Archive'
requirements:
    _access: 'TRUE'
    myvalue: .+

For example:

  • /examplearchiv/testvalue gives $myvalue = 'testvalue' to the controller

  • /examplearchiv/testvalue/value1 causes a "page not found" error

  • /examplearchiv/testvalue/value1/value2 causes a "page not found" error

According to http://symfony.com/doc/current/routing/slash_in_parameter.html myvalue: .+ should also return slashes for {myvalue}; $myvalue should be 'testvalue/test1'.

1
  • I am not sure why this wont work in your case. It should as per this. Apparently seems your route config has some problem with indentation. If so, it can cause the problem. Commented May 2, 2019 at 6:52

1 Answer 1

5

Drupal 8 doesn't support this natively. You can add a simple class in a custom module that implements the InboundPathProcessorInterface that will allow this.

1
  • 1
    Careful with inbountPathProcessors - they influence your menu and a few other things.
    – Darvanen
    Commented May 26, 2021 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.