stream_wrapper_example.routing.yml

Same filename in other branches
  1. 3.x modules/stream_wrapper_example/stream_wrapper_example.routing.yml
  2. 4.0.x modules/stream_wrapper_example/stream_wrapper_example.routing.yml
stream_wrapper_example/stream_wrapper_example.routing.yml
2 string references to YAML keys in stream_wrapper_example.routing.yml
StreamWrapperExampleTest::testRoutes in 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 to provide.

File

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 matched by the router,
  27. # we also need a route defintion to make our URLs. This is never referenced by the
  28. # routing system, but is used by our stream wrapper class to create external URLs.
  29. #
  30. # @see SessionStreamWrapper::getExternalUrl()
  31. #
  32. stream_wrapper_example.files.session:
  33. path: '/examples/stream_wrapper_example/files/{filepath}'
  34. defaults:
  35. _controller: '\Drupal\system\FileDownloadController::download'
  36. scheme: session
  37. requirements:
  38. # Permissive regex to allow slashes in filepath see
  39. # http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html
  40. filepath: .+
  41. _access: 'TRUE'
  42. # Finally, our controller class.
  43. stream_wrapper_example.description:
  44. path: '/examples/stream_wrapper_example'
  45. defaults:
  46. _controller: '\Drupal\stream_wrapper_example\Controller\StreamWrapperExampleController::description'
  47. _title: 'Stream Wrapper Example'
  48. requirements:
  49. _permission: 'access content'