services:
  _defaults:
    autowire: true
    autoconfigure: true

  # get_list action
  xcart.api.storefront.config.data_provider.item.get_list:
    class: XCart\Bundle\APIPlatformBridgeBundle\API\DataProvider\Collection\DataProvider
    arguments:
      $classes: [XCart\API\Entity\Storefront\Config]
      $action: '@xcart.logic.storefront.config.get_list.action'
      $requestAssembler: '@xcart.api.storefront.config.data_provider.collection.request.assembler'
      $responseAssembler: '@xcart.api.storefront.config.data_provider.collection.response.assembler'
      $operationNames: [get]

  xcart.logic.storefront.config.get_list.action:
    class: XCart\Logic\Action\Storefront\Config\GetList\Action
    arguments:
      $responseAssembler: '@xcart.logic.storefront.config.get_collection.response.assembler'
    tags:
      - {name: xcart.logic.action, request: \XCart\Logic\Action\Storefront\Config\GetList\DTO\Request, response: \XCart\Logic\Action\Storefront\Config\GetList\DTO\Response}

  #get_one action
  xcart.api.storefront.config.data_provider.item.get_one_by_id:
    class: XCart\Bundle\APIPlatformBridgeBundle\API\DataProvider\Item\DataProvider
    arguments:
      $classes: [XCart\API\Entity\Storefront\Config]
      $action: '@xcart.logic.storefront.config.get_one_by_id.action'
      $requestAssembler: '@xcart.api.storefront.config.data_provider.item.request.assembler'
      $responseAssembler: '@xcart.api.storefront.config.data_provider.item.response.assembler'
      $operationNames: [get]

  xcart.logic.storefront.config.get_one_by_id.action:
    class: XCart\Logic\Action\Storefront\Config\GetOne\Action
    arguments:
      $responseAssembler: '@xcart.logic.storefront.config.get_one.response.assembler'
      $configValueResolver: '@XCart\Logic\Action\Storefront\Config\ConfigValueResolverInterface'
    tags:
      - {name: xcart.logic.action, request: \XCart\Logic\Action\Storefront\Config\GetOne\DTO\Request, response: \XCart\Logic\Action\Storefront\Config\GetOne\DTO\Response}

  # config value resolver service
  xcart.logic.storefront.config.resolver:
    class: XCart\Logic\Action\Storefront\Config\ConfigValueResolver
    arguments:
      $config: '@xcart.core.config'

  XCart\Logic\Action\Storefront\Config\ConfigValueResolverInterface: '@xcart.logic.storefront.config.resolver'

  xcart.api.storefront.config.data_provider.collection.request.assembler.decorator:
    class: XCart\API\DataProvider\Storefront\Collection\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.config.data_provider.collection.request.assembler
    decoration_priority: 10
    arguments:
      $inner: '@.inner'

  xcart.logic.storefront.config.resolver.currency.decorator:
    class: XCart\Logic\Action\Storefront\Config\ConfigValueResolverCurrencyDecorator
    decorates: xcart.logic.storefront.config.resolver
    decoration_priority: 10
    arguments:
      $inner: '@.inner'
      $xlite: '@xcart.xlite'
