parameters:
  workspaces.skip_procedural_hook_scan: true

services:
  _defaults:
    autoconfigure: true
  workspaces.manager:
    class: Drupal\workspaces\WorkspaceManager
    autowire: true
    tags:
      - { name: service_collector, call: addNegotiator, tag: workspace_negotiator }
  Drupal\workspaces\WorkspaceManagerInterface: '@workspaces.manager'
  workspaces.information:
    class: Drupal\workspaces\WorkspaceInformation
    autowire: true
  Drupal\workspaces\WorkspaceInformationInterface: '@workspaces.information'
  workspaces.operation_factory:
    class: Drupal\workspaces\WorkspaceOperationFactory
    autowire: true
  Drupal\workspaces\WorkspaceOperationFactory: '@workspaces.operation_factory'
  workspaces.association:
    class: Drupal\workspaces\WorkspaceAssociation
    arguments: ['@workspaces.tracker']
    deprecated: The "%service_id%" service is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Use the 'workspaces.tracker' service instead. See https://www.drupal.org/node/3551450
  Drupal\workspaces\WorkspaceAssociationInterface: '@workspaces.association'
  workspaces.tracker:
    class: Drupal\workspaces\WorkspaceTracker
    autowire: true
    tags:
      - { name: backend_overridable }
  Drupal\workspaces\WorkspaceTrackerInterface: '@workspaces.tracker'
  workspaces.repository:
    class: Drupal\workspaces\WorkspaceRepository
    arguments: ['@entity_type.manager', '@cache.default']
  Drupal\workspaces\WorkspaceRepositoryInterface: '@workspaces.repository'

  Drupal\workspaces\Provider\WorkspaceProviderCollector:
    autowire: true
  Drupal\workspaces\Provider\DefaultWorkspaceProvider:
    autowire: true

  workspaces.negotiator.session:
    class: Drupal\workspaces\Negotiator\SessionWorkspaceNegotiator
    autowire: true
    tags:
      - { name: workspace_negotiator, priority: 50 }
  workspaces.negotiator.query_parameter:
    class: Drupal\workspaces\Negotiator\QueryParameterWorkspaceNegotiator
    parent: workspaces.negotiator.session
    tags:
      - { name: workspace_negotiator, priority: 100 }

  access_check.workspaces.active_workspace:
    class: Drupal\workspaces\Access\ActiveWorkspaceCheck
    arguments: ['@workspaces.manager']
    tags:
      - { name: access_check, applies_to: _has_active_workspace }

  workspaces.entity_schema_listener:
    class: Drupal\workspaces\EventSubscriber\EntitySchemaSubscriber
    arguments: ['@entity.definition_update_manager', '@entity.last_installed_schema.repository', '@workspaces.information']
  workspaces.workspace_subscriber:
    class: Drupal\workspaces\EventSubscriber\WorkspaceRequestSubscriber
    arguments: ['@router.route_provider', '@workspaces.manager']
  Drupal\workspaces\EventSubscriber\WorkspaceSwitchSubscriber:
    autowire: true

  cache_context.workspace:
    class: Drupal\workspaces\WorkspaceCacheContext
    arguments: ['@workspaces.manager']
    tags:
      - { name: cache.context }
  logger.channel.workspaces:
    parent: logger.channel_base
    arguments: ['workspaces']

  workspaces.lazy_builders:
    class: Drupal\workspaces\WorkspacesLazyBuilders
    arguments: [ '@workspaces.manager', '@plugin.manager.element_info' ]
  Drupal\workspaces\WorkspacesLazyBuilders: '@workspaces.lazy_builders'

  workspaces.entity.repository:
    decorates: entity.repository
    class: Drupal\workspaces\WorkspacesEntityRepository
    arguments: ['@.inner', '@workspaces.manager']
    public: false

  workspaces.entity.query.sql:
    decorates: entity.query.sql
    class: Drupal\workspaces\EntityQuery\QueryFactory
    arguments: ['@database', '@workspaces.manager', '@workspaces.information']
    public: false
    decoration_priority: 50
    tags:
      - { name: backend_overridable }

  workspaces.menu.tree_storage:
    decorates: menu.tree_storage
    class: Drupal\workspaces\WorkspacesMenuTreeStorage
    arguments: ['@workspaces.manager', '@workspaces.tracker', '@entity_type.manager', '@database', '@cache.menu', '@cache_tags.invalidator', 'menu_tree']
    public: false
    decoration_priority: 50
    tags:
      - { name: backend_overridable }

  workspaces.controller.entity_form:
    # Decorate the entity form controller to handle entity operations inside a
    # workspace.
    decorates: controller.entity_form
    class: Drupal\workspaces\Controller\WorkspacesHtmlEntityFormController
    public: false
    arguments: ['@.inner', '@workspaces.manager', '@workspaces.information', '@typed_data_manager']
  Drupal\workspaces\Controller\WorkspacesHtmlEntityFormController: '@workspaces.controller.entity_form'

  Drupal\workspaces\WorkspacesCron:
    decorates: cron
    decoration_priority: -100
    autowire: true
    public: false
