services:
  purl.plugin.method_manager:
    class: Drupal\purl\Plugin\MethodPluginManager
    parent: default_plugin_manager
    calls:
      - [setContainer, [ '@service_container' ]]

  purl.plugin.provider_manager:
    class: Drupal\purl\Plugin\ProviderManager
    parent: default_plugin_manager
    calls:
      - [setContainer, [ '@service_container' ]]
      - [setConnection, [ '@database' ]]

  purl.modifier_index:
    class: Drupal\purl\Plugin\ModifierIndex
    arguments:
      - '@purl.plugin.provider_manager'
      - '@database'

  #purl.identifier_provider.composite:
    #class: Drupal\purl\Plugin\Purl\Identifier\CompositeIdentifierProvider
    #arguments:
        #- [ '@purl.identifier_provider.test' ]

  purl.request_subscriber:
    class: Drupal\purl\Event\RequestSubscriber
    arguments: 
      - '@purl.modifier_index'
      - '@purl.plugin.provider_manager'
      - '@purl.plugin.method_manager'
      - '@purl.matched_modifiers'
    tags:
      - { name: event_subscriber }

  cache_context.purl:
    class: Drupal\purl\Cache\Context\PurlCacheContext
    tags:
      - { name: event_subscriber }
      - { name: cache.context }

  purl.rebuild_index:
    class: Drupal\purl\Event\RebuildIndex
    arguments: 
      - '@purl.modifier_index'
    tags:
      - { name: event_subscriber }

  purl.outbound_path_processor:
    class: Drupal\purl\PathProcessor\PurlContextOutboundPathProcessor
    arguments: 
      - '@purl.plugin.method_manager'
    tags:
      - { name: event_subscriber }
      - { name: path_processor_outbound, priority: 300 }

  purl.outbound_route_processor:
    class: Drupal\purl\RouteProcessor\PurlContextOutboundRouteProcessor
    arguments:
      - '@purl.plugin.method_manager'
    tags:
      - { name: event_subscriber }
      - { name: route_processor_outbound, priority: 300 }

  # @TODO: Consider decorating @url_generator.non_bubbling instead.
  purl.url_generator:
    class: Drupal\purl\Routing\UrlGenerator
    arguments: ['@url_generator.non_bubbling']
    calls:
      - [setContext, ['@?router.request_context']]

  purl.matched_modifiers:
    class: Drupal\purl\MatchedModifiers

