stream_wrapper_example.routing.yml

Same filename in other branches
  1. 3.x modules/stream_wrapper_example/stream_wrapper_example.routing.yml
  2. 8.x-1.x stream_wrapper_example/stream_wrapper_example.routing.yml
modules/stream_wrapper_example/stream_wrapper_example.routing.yml
2 string references to YAML keys in stream_wrapper_example.routing.yml
StreamWrapperExampleTest::testRoutes in modules/stream_wrapper_example/tests/src/Functional/StreamWrapperExampleTest.php
Make sure all the public routes behave the way they should.
_examples_toolbar_routes in ./examples.module
Get a list of toolbar links for testing toolbar routes.

File

modules/stream_wrapper_example/stream_wrapper_example.routing.yml

View source
  1. # In order to view files created with our demo stream wrapper class,
  2. # we need to use hook_file_download to grant any access. This route
  3. # will make sure that we have an external URL for these files, and that
  4. # our hook is called.
  5. #
  6. # In our implementation, access to the files is actually managed by
  7. # permissions defined in file_example.permissions.yml. Since we also want our
  8. # URLs to be served similar to how private: and temporary: URI are served by
  9. # core, we also need to modify how the routing system handles the tail portion
  10. # of the URL. Unlike Drupal 7, Drupal 8 does not ordinarily allow a "menu tail";
  11. # URLs need to be of a definite length or the router will not process them. To
  12. # get around this, we also implement a "path processor", which we define as a
  13. # service in our services file. Our path processor will do the extra steps needed
  14. # to process our session file URLs.
  15. #
  16. # @see stream_wrapper_example.services.yml
  17. # @see file_example_file_download()
  18. #
  19. stream_wrapper_example.files:
  20. path: '/examples/stream_wrapper_example/files/{scheme}'
  21. defaults:
  22. _controller: 'Drupal\system\FileDownloadController::download'
  23. scheme: session
  24. requirements:
  25. _access: 'TRUE'
  26. # In addition to the stream_wrapper_example.files route, which is actually
  27. # matched by the router, we also need a route definition to make our URLs.
  28. # This is never referenced by the routing system, but it is used by our stream
  29. # wrapper class to create external URLs.
  30. #
  31. # @see SessionStreamWrapper::getExternalUrl()
  32. #
  33. stream_wrapper_example.files.session:
  34. path: '/examples/stream_wrapper_example/files/{filepath}'
  35. defaults:
  36. _controller: '\Drupal\system\FileDownloadController::download'
  37. scheme: session
  38. requirements:
  39. # Permissive regex to allow slashes in filepath see
  40. # http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html
  41. filepath: .+
  42. _access: 'TRUE'
  43. # Finally, our controller class.
  44. stream_wrapper_example.description:
  45. path: '/examples/stream_wrapper_example'
  46. defaults:
  47. _controller: '\Drupal\stream_wrapper_example\Controller\StreamWrapperExampleController::description'
  48. _title: 'Stream Wrapper Example'
  49. requirements:
  50. _permission: 'access content'