parameters:
    oro_payment_term.type: 'payment_term'

services:
    oro_payment_term.form.autocomplete.payment_term.search_handler:
        parent: oro_form.autocomplete.search_handler
        arguments:
            - 'Oro\Bundle\PaymentTermBundle\Entity\PaymentTerm'
            - ['label']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: Oro\Bundle\PaymentTermBundle\Form\Type\PaymentTermType, acl_resource: oro_payment_term_view }

    oro_payment_term.payment_term.delete_message_generator:
        class: 'Oro\Bundle\PaymentTermBundle\Twig\DeleteMessageTextGenerator'
        public: true
        arguments:
            - "@router"
            - "@twig"
            - "@oro_payment_term.manager"

    oro_payment_term.manager:
        class: 'Oro\Bundle\PaymentTermBundle\Manager\PaymentTermManager'
        arguments:
            - "@oro_entity.doctrine_helper"
            - "@oro_payment_term.provider.payment_term_association"

    oro_payment_term.twig.delete_message_text_extension:
        class: 'Oro\Bundle\PaymentTermBundle\Twig\DeleteMessageTextExtension'
        public: false
        arguments:
            - "@oro_platform.twig.service_locator"
        tags:
            - { name: twig.extension }

    oro_payment_term.event_listener.datagrid:
        class: 'Oro\Bundle\PaymentTermBundle\EventListener\DatagridListener'
        arguments:
            - '@oro_payment_term.provider.payment_term_association'
            - '@oro_payment_term.provider.payment_term'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before, method: onBuildBefore }

    oro_payment_term.event_listener.customer_datagrid:
        class: 'Oro\Bundle\PaymentTermBundle\EventListener\CustomerDatagridListener'
        arguments:
            - '@oro_payment_term.provider.payment_term_association'
            - '@oro_datagrid.provider.selected_fields'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.customer-customers-select-grid, method: onBuildBefore, priority: 128 }

    Oro\Bundle\PaymentTermBundle\Provider\PaymentTermProvider:
        alias: oro_payment_term.provider.payment_term

    oro_payment_term.provider.payment_term:
        class: 'Oro\Bundle\PaymentTermBundle\Provider\PaymentTermProvider'
        public: true
        arguments:
            - '@security.token_storage'
            - '@event_dispatcher'
            - '@oro_payment_term.provider.payment_term_association'
        tags:
            - { name: layout.data_provider, alias: oro_payment_term_provider }

    oro_payment_term.provider.payment_term_association:
        class: 'Oro\Bundle\PaymentTermBundle\Provider\PaymentTermAssociationProvider'
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_entity_config.provider.extend'
            - '@property_accessor'

    oro_payment_term.migration.extension.payment_term:
        class: 'Oro\Bundle\PaymentTermBundle\Migration\Extension\PaymentTermExtension'
        tags:
            - { name: oro_migration.extension, extension_name: payment_term }

    oro_payment_term.listener.value_render:
        class: 'Oro\Bundle\PaymentTermBundle\EventListener\ValueRenderEventListener'
        arguments:
            - '@oro_payment_term.provider.payment_term_association'
            - '@translator'
            - '@router'
        tags:
            - { name: kernel.event_listener, event: oro.entity_extend_event.before_value_render, method: beforeValueRender }

    oro_payment_term.config.integration_method_identifier_generator:
        parent: oro_integration.generator.prefixed_identifier_generator
        public: true
        arguments:
            - '%oro_payment_term.type%'

    oro_payment_term.config.by_settings_factory_parameter_bag:
        class: 'Oro\Bundle\PaymentTermBundle\Method\Config\ParameterBag\Factory\Settings\ParameterBagPaymentTermConfigBySettingsFactory'
        public: false
        arguments:
            - '@oro_locale.helper.localization'
            - '@oro_payment_term.config.integration_method_identifier_generator'

    oro_payment_term.config.provider:
        parent: oro_payment_term.config.provider_basic_memory_cached

    # use oro_payment_term.config.provider in general
    oro_payment_term.config.provider_basic:
        class: 'Oro\Bundle\PaymentTermBundle\Method\Config\Provider\Basic\BasicPaymentTermConfigProvider'
        public: false
        arguments:
            - '@doctrine'
            - '@logger'
            - '@oro_payment_term.config.by_settings_factory_parameter_bag'

    # use oro_payment_term.config.provider in general
    oro_payment_term.config.provider_basic_memory_cached:
        class: 'Oro\Bundle\PaymentTermBundle\Method\Config\Provider\Cached\Memory\CachedMemoryPaymentTermConfigProvider'
        public: false
        arguments:
            - '@oro_payment_term.config.provider_basic'

    oro_payment_term.repository.payment_term_settings:
        alias: Oro\Bundle\PaymentTermBundle\Entity\Repository\PaymentTermSettingsRepository

    Oro\Bundle\PaymentTermBundle\Entity\Repository\PaymentTermSettingsRepository:
        parent: oro_entity.abstract_repository
        arguments:
            - 'Oro\Bundle\PaymentTermBundle\Entity\PaymentTermSettings'
        calls:
            - [setAclHelper, ['@oro_security.acl_helper']]
        tags:
            - { name: doctrine.repository_service }

    oro_payment_term.event_listener.import_export_customer_subscriber:
        class: Oro\Bundle\PaymentTermBundle\EventListener\CustomerImportExportSubscriber
        arguments:
            - '@oro_payment_term.provider.payment_term_association'
        tags:
            - { name: kernel.event_subscriber }

    oro_payment_term.twig.payment_term_extension:
        class: 'Oro\Bundle\PaymentTermBundle\Twig\PaymentTermExtension'
        public: false
        arguments:
            - "@oro_platform.twig.service_locator"
        tags:
            - { name: twig.extension }
