services:
  _defaults:
    public: true

  # Filters builder argument resolver
  prestashop.filters_builder.resolver:
    class: 'PrestaShopBundle\Controller\ArgumentResolver\FiltersBuilderResolver'
    arguments:
      - '@prestashop.core.search.builder'
    tags:
      - { name: controller.argument_value_resolver, priority: 51 }

  prestashop.core.search.builder.typed:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\TypedFiltersBuilder'
    arguments:
      - '@prestashop.core.search.builder.class'
      - !tagged core.typed_filters_builder

  prestashop.core.search.builder.class:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\ClassFiltersBuilder'

  prestashop.core.search.builder.request:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\RequestFiltersBuilder'

  prestashop.core.search.builder.repository:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\RepositoryFiltersBuilder'
    arguments:
      - '@prestashop.core.admin.admin_filter.repository'
      - '@prestashop.adapter.data_provider.employee'
      - '@=service("prestashop.adapter.legacy.context").getContext().shop.id'

  prestashop.core.search.builder.event:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\EventFiltersBuilder'
    arguments:
      - '@event_dispatcher'

  prestashop.core.search.builder.persist:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\PersistFiltersBuilder'
    arguments:
      - '@prestashop.core.admin.admin_filter.repository'
      - '@prestashop.adapter.data_provider.employee'
      - '@=service("prestashop.adapter.legacy.context").getContext().shop.id'

  prestashop.core.search.builder:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\ChainedFiltersBuilder'
    arguments:
      - - '@prestashop.core.search.builder.typed'
        - '@prestashop.core.search.builder.repository'
        - '@prestashop.core.search.builder.request'
        - '@prestashop.core.search.builder.event'
        - '@prestashop.core.search.builder.persist'

  prestashop.core.api.search.builder:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\ChainedFiltersBuilder'
    arguments:
      - - '@prestashop.core.search.builder.typed'
        - '@prestashop.core.search.builder.request'
        - '@prestashop.core.search.builder.event'

  # Typed builders (they will be automatically added to TypeFiltersBuilder thanks to their tag)
  prestashop.core.search.builder.typed_builder.product_combination_filters_builder:
    class: 'PrestaShop\PrestaShop\Core\Search\Builder\TypedBuilder\ProductCombinationFiltersBuilder'
    tags: [ 'core.typed_filters_builder' ]

  PrestaShop\PrestaShop\Core\Search\Builder\TypedBuilder\FeatureValueFiltersBuilder:
    autowire: true
    tags: [ 'core.typed_filters_builder' ]
