stream_wrapper_example.services.yml

Same filename in other branches
  1. 4.0.x modules/stream_wrapper_example/stream_wrapper_example.services.yml
modules/stream_wrapper_example/stream_wrapper_example.services.yml

File

modules/stream_wrapper_example/stream_wrapper_example.services.yml

View source
  1. #
  2. # As part of our demo, we implement a simple "file system" that lets us read and
  3. # write files out of the session object. This isn't very practical, but it's a
  4. # simple way to demonstrate what you can do with PHP's stream wrappers.
  5. #
  6. # To get a stream wrapper to work to define a stream wrapper class, we need to
  7. # register that with the system. We can either do this manually by calling up
  8. # the 'stream_wrapper.manager' service, but the better way to do this is to have
  9. # the system autoload it by tagging the service, as we do here.
  10. #
  11. # We also want to securely serve up our fake session files. We'd like to use the
  12. # same nice file paths that Core uses for private files. Since Drupal 8 no
  13. # longer allows us to have "menu tails" (i.e., extra/parts/of/the/path after the
  14. # default part of the path), we need to get some router superpowers. Our route
  15. # (in stream_wrapper_example.routing.yml) will "gather up" the path with with a
  16. # regular expression. But we need to do a little more that that. We also need
  17. # to convince the routing system to see our weird, extra long route route. We do
  18. # that using a "Path Processor". We register the path_process.sessions service
  19. # with special tags to get it loaded for when the Drupal's routing system
  20. # decides which path should get used.
  21. #
  22. # @see src/StreamWrapper/SessionStreamWrapper.php
  23. # @see src/PathProcessor/PathProcessorSessions.php
  24. # @see stream_wrapper_example.routing.yml
  25. #
  26. services:
  27. stream_wrapper_example.stream_wrapper:
  28. class: Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper
  29. tags:
  30. - { name: stream_wrapper, scheme: session }
  31. arguments: ['@stream_wrapper_example.session_helper']
  32. stream_wrapper_example.session_helper:
  33. class: Drupal\stream_wrapper_example\SessionHelper
  34. arguments: ['@request_stack']
  35. path_processor.sessions:
  36. class: Drupal\stream_wrapper_example\PathProcessor\PathProcessorSessions
  37. tags:
  38. - { name: path_processor_inbound, priority: 200 }

Services

Title Deprecated Summary
path_processor.sessions Drupal\stream_wrapper_example\PathProcessor\PathProcessorSessions
stream_wrapper_example.session_helper Drupal\stream_wrapper_example\SessionHelper
stream_wrapper_example.stream_wrapper Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper