services:
  _defaults:
    public: true

  # Command validator
  prestashop.adapter.currency.command_handler.command_validator:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\CurrencyCommandValidator'
    arguments:
      - '@prestashop.core.localization.cldr.locale_repository'
      - '@prestashop.adapter.data_provider.currency'
      - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")'

  # Command handlers

  prestashop.adapter.currency.command_handler.toggle_currency_status:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\ToggleCurrencyStatusHandler'
    arguments:
      - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleCurrencyStatusCommand' }

  prestashop.adapter.currency.command_handler.delete_currency:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\DeleteCurrencyHandler'
    arguments:
      - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\DeleteCurrencyCommand' }

  prestashop.adapter.currency.command_handler.create_currency:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\AddOfficialCurrencyHandler'
    arguments:
      - '@prestashop.core.localization.cldr.locale_repository'
      - "@=service('prestashop.core.admin.lang.repository').findAll()"
      - "@prestashop.adapter.currency.command_handler.command_validator"
      - '@prestashop.adapter.data_provider.currency'
      - '@prestashop.core.localization.currency.pattern_transformer'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddCurrencyCommand' }

  prestashop.adapter.currency.command_handler.create_unofficial_currency:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\AddUnofficialCurrencyHandler'
    arguments:
      - '@prestashop.core.localization.cldr.locale_repository'
      - "@=service('prestashop.core.admin.lang.repository').findAll()"
      - "@prestashop.adapter.currency.command_handler.command_validator"
      - '@prestashop.adapter.data_provider.currency'
      - '@prestashop.core.localization.currency.pattern_transformer'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddUnofficialCurrencyCommand' }

  prestashop.adapter.currency.command_handler.update_official_currency:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\EditOfficialCurrencyHandler'
    arguments:
      - '@prestashop.core.localization.cldr.locale_repository'
      - "@=service('prestashop.core.admin.lang.repository').findAll()"
      - "@prestashop.adapter.currency.command_handler.command_validator"
      - "@prestashop.core.localization.currency.pattern_transformer"
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditCurrencyCommand' }

  prestashop.adapter.currency.command_handler.update_unofficial_currency:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\EditUnofficialCurrencyHandler'
    arguments:
      - '@prestashop.core.localization.cldr.locale_repository'
      - "@=service('prestashop.core.admin.lang.repository').findAll()"
      - "@prestashop.adapter.currency.command_handler.command_validator"
      - "@prestashop.core.localization.currency.pattern_transformer"
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditUnofficialCurrencyCommand' }

  prestashop.adapter.currency.command_handler.update_exchange_rates:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\RefreshExchangeRatesHandler'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\RefreshExchangeRatesCommand' }

  prestashop.adapter.currency.command_handler.bulk_toggle_currencies_status_handler:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\BulkToggleCurrenciesStatusHandler'
    arguments:
      - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")'
    tags:
      - { name: tactician.handler, command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\BulkToggleCurrenciesStatusCommand' }

  prestashop.adapter.currency.command_handler.bulk_delete_currencies_handler:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\BulkDeleteCurrenciesHandler'
    arguments:
      - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")'
    tags:
      - { name: tactician.handler, command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\BulkDeleteCurrenciesCommand' }


  # Query handlers

  prestashop.adapter.currency.query_handler.get_currency_for_editing:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\QueryHandler\GetCurrencyForEditingHandler'
    arguments:
      - '@=service("prestashop.adapter.legacy.context").getContext().shop.id'
      - '@prestashop.core.localization.currency.pattern_transformer'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyForEditing' }

  prestashop.adapter.currency.query_handler.get_currency_exchange_rate:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\QueryHandler\GetCurrencyExchangeRateHandler'
    arguments:
      - '@prestashop.core.exchange_rate.provider'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyExchangeRate' }

  prestashop.adapter.currency.query_handler.get_reference_currency:
    class: 'PrestaShop\PrestaShop\Adapter\Currency\QueryHandler\GetReferenceCurrencyHandler'
    arguments:
      - '@prestashop.core.localization.cldr.locale_repository'
      - '@=service("prestashop.core.admin.lang.repository").findAll()'
    tags:
      - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetReferenceCurrency' }

  PrestaShop\PrestaShop\Adapter\Currency\Repository\CurrencyRepository: ~

  prestashop.adapter.currency.repository.currency_repository:
    alias: PrestaShop\PrestaShop\Adapter\Currency\Repository\CurrencyRepository
    deprecated: ~
