services:
  _defaults:
    autowire: true
    autoconfigure: true

  # transformers
  XCart\Transformer\XLite\Model\Product\Logic\Entity\Storefront\Product:
    class: XCart\Transformer\XLite\Model\Product\Logic\Entity\Storefront\Product
    arguments:
      $factory: '@XCart\Factory\Logic\Entity\Storefront\ProductInterface'

  XCart\Transformer\XLite\Model\AttributeValue\Logic\Entity\Storefront\AttributeValue:
    class: XCart\Transformer\XLite\Model\AttributeValue\Logic\Entity\Storefront\AttributeValue
    arguments:
      $factory: '@XCart\Factory\Logic\Entity\Storefront\ProductAttributeValueInterface'

  # get one by id
  xcart.logic.storefront.product.get_one_by_id.action:
    class: XCart\Logic\Action\Storefront\Product\GetOne\Action
    arguments:
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_id.assembler.query_builder'
      $responseAssembler: '@xcart.logic.storefront.product.get_one.response.assembler'
    tags:
      - {name: xcart.logic.action, request: XCart\Logic\Action\Storefront\Product\GetOne\DTO\Request, response: XCart\Logic\Action\Storefront\Product\GetOne\DTO\Response}

  xcart.logic.storefront.product.get_one_by_id.assembler.query_builder:
    class: XCart\Logic\Action\Storefront\Product\GetOne\Assembler\QueryBuilder\FindOneQueryBuilderAssembler
    arguments:
      $productRepository: '@xcart.repository.product.read'
      $entityIdAssembler: '@xcart.logic.storefront.product.get_one.action.entity_id.assembler'

  xcart.logic.storefront.product.get_one_by_id.action.decorator.path:
    class: XCart\Logic\Action\Storefront\Product\GetOne\ProductPathActionDecorator
    decorates: xcart.logic.storefront.product.get_one_by_id.action
    decoration_priority: 40
    arguments:
      $inner: '@.inner'
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_id.assembler.query_builder'
      $categoryRepository: '@xcart.repository.category.read'

  # get one by clean url
  xcart.logic.storefront.product.get_one_by_clean_url.action:
    class: XCart\Logic\Action\Storefront\Product\GetOne\Action
    arguments:
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_clean_url.assembler.query_builder'
      $responseAssembler: '@xcart.logic.storefront.product.get_one.response.assembler'
    tags:
      - {name: xcart.logic.action, request: XCart\Logic\Action\Storefront\Product\Detailed\GetOneByCleanURL\DTO\Request, response: XCart\Logic\Action\Storefront\Product\Detailed\GetOneByCleanURL\DTO\Response}

  xcart.logic.storefront.product.get_one_by_clean_url.assembler.query_builder:
    class: XCart\Logic\Action\Storefront\Product\GetOne\Assembler\QueryBuilder\FindOneQueryBuilderAssembler
    arguments:
      $productRepository: '@xcart.repository.product.read'
      $entityIdAssembler: '@xcart.logic.storefront.product.get_one_by_clean_url.action.entity_id.assembler'

  xcart.logic.storefront.product.get_one_by_clean_url.action.entity_id.assembler:
    class: XCart\Logic\Action\Storefront\Product\Detailed\GetOneByCleanURL\Assembler\EntityIdAssembler
    arguments:
      $cleanURLRepository: '@xcart.repository.clean_url'

  xcart.logic.storefront.product.get_one_by_clean_url.action.decorator.path:
    class: XCart\Logic\Action\Storefront\Product\GetOne\ProductPathActionDecorator
    decorates: xcart.logic.storefront.product.get_one_by_clean_url.action
    decoration_priority: 40
    arguments:
      $inner: '@.inner'
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_clean_url.assembler.query_builder'
      $categoryRepository: '@xcart.repository.category.read'

  # get list
  xcart.doctrine.storefront.product.criteria.assembler.decorator.enabled:
    class: XCart\Logic\Action\Storefront\Product\GetList\Assembler\Criteria\FindListCriteriaAssemblerDecorator
    decorates: xcart.doctrine.storefront.product.criteria.assembler
    decoration_priority: 10
    arguments:
      '$inner': '@.inner'
