framework:
  secret: "%secret%"

parameters:
  secret: '%env(APP_SECRET)%'
  legacy.dir: '%kernel.project_dir%/public/legacy'
  legacy.path: '/legacy'
  legacy.session_name: 'LEGACYSESSID'
  default_session_name: 'PHPSESSID'

imports:
  - { resource: services/**/*.yaml }
  - { resource: modules/**/*.yaml }
  - { resource: modules/**/*.php }

services:
  # default configuration for services in *this* file
  _defaults:
    autowire: true      # Automatically injects dependencies in your services.
    autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
    public: false       # Allows optimizing the container by removing unused services.
    bind:
      $projectDir: '%kernel.project_dir%'
      $legacyDir: '%legacy.dir%'
      $legacyPath: '%legacy.path%'
      $legacySessionName: '%legacy.session_name%'
      $defaultSessionName: '%default_session_name%'
      $moduleRouting: '%legacy.module_routing%'
      $exposedSystemConfigs: '%legacy.exposed_system_configs%'
      $systemConfigKeyMap: '%legacy.system_config_key_map%'
      $menuItemMap: '%legacy.menu_item_map%'
      $legacyAssetPaths: '%legacy.asset_paths%'
      $legacyApiPaths: '%legacy.api_paths%'
      $exposedUserPreferences: '%legacy.exposed_user_preferences%'
      $userPreferencesKeyMap: '%legacy.user_preferences_key_map%'
      $themeImagePaths: '%themes.image_paths%'
      $themeImageSupportedTypes: '%themes.image_supported_types%'
      $frontendExcludedModules: '%legacy.frontend_excluded_modules%'
      $datetimeFormatMap: '%legacy.datetime_format_map%'
      $filterOperatorMap: '%legacy.filter_operator_map%'
      $cacheResetActions: '%legacy.cache_reset_actions%'
      $navigationTabLimits: '%themes.navigation_tab_limits%'
      $listViewBulkActions: '%module.listview.bulk_action%'
      $listViewLineActions: '%module.listview.line_action%'
      $listViewSidebarWidgets: '%module.listview.sidebar_widgets%'
      $listViewColumnLimits: '%module.listview.column_limits%'
      $listViewSettingsLimits: '%module.listview.settings_limits%'
      $listViewActionsLimits: '%module.listview.actions_limits%'
      $recordViewActions: '%module.recordview.actions%'
      $recordViewActionLimits: '%module.recordview.actions_limits%'
      $uiConfigs: '%ui%'
  _instanceof:
    App\Service\ProcessHandlerInterface:
      tags: [ 'app.process.handler' ]
    App\Legacy\UserPreferences\UserPreferencesMapperInterface:
      tags: [ 'user.preferences.mapper' ]
    App\Legacy\SystemConfig\SystemConfigMapperInterface:
      tags: [ 'system.config.mapper' ]
    App\Legacy\Data\PresetListDataHandlerInterface:
      tags: [ 'app.data.preset.handler' ]
    App\Legacy\Data\FilterMapper\FilterMapperInterface:
      tags: [ 'app.data.filter.mapper' ]
    App\Service\StatisticsProviderInterface:
      tags: [ 'app.data.statistics.handler' ]

  # makes classes in src/ available to be used as services
  # this creates a service per class whose id is the fully-qualified class name
  App\:
    resource: '../core/src/*'
    exclude: '../core/src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

  # makes classes in legacy/ available to be used as services
  # this creates a service per class whose id is the fully-qualified class name
  App\Legacy\:
    resource: '../core/legacy/*'

  # controllers are imported separately to make sure services can be injected
  # as action arguments even if you don't extend any base controller class
  App\Controller\:
    resource: '../core/src/Controller/*'
    tags: [ 'controller.service_arguments' ]

  # add more service definitions when explicit configuration is needed
  # please note that last definitions always *replace* previous ones

  App\EventListener\LegacyRedirectListener:
    # set priority of 2050 to ensure the be the first running
    tags: [ { name: kernel.event_listener, event: kernel.request, priority: 2050 } ]

  App\Service\ProcessHandlerRegistry:
    # inject all services tagged with app.process.handler as first argument
    # and use the value of the 'getProcessType' method to index the services
    arguments:
      - !tagged { tag: 'app.process.handler', default_index_method: 'getProcessType' }

  App\Security\LegacySessionDenyAccessListener:
    decorates: 'api_platform.security.listener.request.deny_access'

  App\Security\LegacySessionSecurityStage:
    decorates: 'api_platform.graphql.resolver.stage.security'

  App\Security\LegacySessionLogoutHandler:
    decorates: 'security.logout.handler.session'

  App\Security\RouteMatcher:
    class: App\Security\RouteMatcher
    public: false

  App\Security\CSRFTokenManager:
    class: App\Security\CSRFTokenManager
    public: false
    arguments:
      $tokenId: 'angular'

  App\Security\CSRFCookieListener:
    tags: [ { name: kernel.event_listener, event: kernel.response, method: onKernelResponse } ]
    arguments:
      $routes: [ '^/' ]
      $cookieName: 'XSRF-TOKEN'
      $cookieExpire: 0
      $cookiePath: /
      $cookieDomain: ~
      $cookieSecure: false

  App\Security\CSRFValidationListener:
    tags: [ { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 12 } ]
    arguments:
      $routes: [  ]
      $headerName: 'X-XSRF-TOKEN'

  App\Legacy\UserPreferences\UserPreferencesMappers:
    # inject all services tagged with user.preferences.mapper as first argument
    # and use the value of the 'getKey' method to index the services
    arguments:
      - !tagged { tag: 'user.preferences.mapper', default_index_method: 'getKey' }

  App\Legacy\SystemConfig\SystemConfigMappers:
    # inject all services tagged with system.config.mapper as first argument
    # and use the value of the 'getKey' method to index the services
    arguments:
      - !tagged { tag: 'system.config.mapper', default_index_method: 'getKey' }

  App\Legacy\Data\PresetListDataHandlers:
    # inject all services tagged with app.data.preset.handler as first argument
    # and use the value of the 'getType' method to index the services
    arguments:
      - !tagged { tag: 'app.data.preset.handler', default_index_method: 'getType' }

  App\Service\StatisticsProviderRegistry:
    # inject all services tagged with app.data.statistics.handler as first argument
    # and use the value of the 'getKey' method to index the services
    arguments:
      - !tagged { tag: 'app.data.statistics.handler', default_index_method: 'getKey' }

  App\Legacy\Data\FilterMapper\FilterMappers:
    # inject all services tagged with app.data.filter.mapper as first argument
    # and use the value of the 'getType' method to index the services
    arguments:
      - !tagged { tag: 'app.data.filter.mapper', default_index_method: 'getType' }
