parameters:
    # entity
    orocrm_channel.entity.class:                                       OroCRM\Bundle\ChannelBundle\Entity\Channel

    # builder
    orocrm_channel.builder.factory.class:                              OroCRM\Bundle\ChannelBundle\Builder\BuilderFactory

    # handlers
    orocrm_channel.channel_form.handler.class:                         OroCRM\Bundle\ChannelBundle\Form\Handler\ChannelHandler
    orocrm_channel.channel_integration_form.handler.class:             OroCRM\Bundle\ChannelBundle\Form\Handler\ChannelIntegrationHandler

    # forms
    orocrm_channel.form.type.channel.class:                               OroCRM\Bundle\ChannelBundle\Form\Type\ChannelType
    orocrm_channel.form.type.entity.class:                                OroCRM\Bundle\ChannelBundle\Form\Type\ChannelEntityType
    orocrm_channel.form.type.channel_datasource.class:                    OroCRM\Bundle\ChannelBundle\Form\Type\ChannelDatasourceType
    orocrm_channel.form.type.channel_select.class:                        OroCRM\Bundle\ChannelBundle\Form\Type\ChannelSelectType
    orocrm_channel.form.type.create_or_select_inline_channel_aware.class: OroCRM\Bundle\ChannelBundle\Form\Type\CreateOrSelectInlineChannelAwareType
    orocrm_channel.form.type.multiple_entity_channel_aware.class:         OroCRM\Bundle\ChannelBundle\Form\Type\MultipleEntityChannelAwareType
    orocrm_channel.form.embedded_type_extension.class:                    OroCRM\Bundle\ChannelBundle\Form\Extension\EmbeddedFormTypeExtension
    orocrm_channel.form.integration_type_extension.class:                 OroCRM\Bundle\ChannelBundle\Form\Extension\IntegrationTypeExtension


    # manager
    orocrm_channel.manager.api.class:                                  Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager

    # providers
    orocrm_channel.provider.settings_provider.class:                   OroCRM\Bundle\ChannelBundle\Provider\SettingsProvider
    orocrm_channel.provider.exclusion_provider.class:                  OroCRM\Bundle\ChannelBundle\Provider\EntityExclusionProvider
    orocrm_channel.provider.channel_entity_exclusion_provider.class:   OroCRM\Bundle\ChannelBundle\Provider\ChannelEntityExclusionProvider
    orocrm_channel.provider.state_provider.class:                      OroCRM\Bundle\ChannelBundle\Provider\StateProvider
    orocrm_channel.provider.entity_metadata.class:                     OroCRM\Bundle\ChannelBundle\Provider\MetadataProvider
    orocrm_channel.provider.utils.entity_state_provider.class:         OroCRM\Bundle\ChannelBundle\Provider\Utility\EntityStateProvider
    orocrm_channel.provider.request_channel.class:                     OroCRM\Bundle\ChannelBundle\Provider\RequestChannelProvider
    orocrm_channel.provider.lifetime.amount_provider.class:            OroCRM\Bundle\ChannelBundle\Provider\Lifetime\AmountProvider
    orocrm_channel.provider.lifetime.average_widget_provider.class:    OroCRM\Bundle\ChannelBundle\Provider\Lifetime\AverageLifetimeWidgetProvider

    # datagrid
    orocrm_channel.datagrid.extension.orm_channel_limitation.class:    OroCRM\Bundle\ChannelBundle\Datagrid\ChannelLimitationExtension

    # autocomplete
    orocrm_channel.autocomplete.channel_limitation_handler.class:      OroCRM\Bundle\ChannelBundle\Autocomplete\ChannelLimitationHandler

    # config resolver
    orocrm_channel.config_resolver.class:                              Oro\Component\Config\Resolver\SystemAwareResolver

    # event listener
    orocrm_channel.event_listener.navigation.class:                    OroCRM\Bundle\ChannelBundle\EventListener\NavigationListener
    orocrm_channel.form.subscriber.channel_subscriber.class:           OroCRM\Bundle\ChannelBundle\Form\EventListener\ChannelTypeSubscriber
    orocrm_channel.event_listener.channel_change_status.class:         OroCRM\Bundle\ChannelBundle\EventListener\ChangeChannelStatusListener
    orocrm_channel.event_listener.channel_save_succeed.class:          OroCRM\Bundle\ChannelBundle\EventListener\ChannelSaveSucceedListener
    orocrm_channel.event_listener.channel_before_deleted.class:        OroCRM\Bundle\ChannelBundle\EventListener\ChannelBeforeDeleteListener
    orocrm_channel.event_listener.embedded_form.class:                 OroCRM\Bundle\ChannelBundle\EventListener\EmbeddedFormListener
    orocrm_channel.event_listener.doctrine.class:                      OroCRM\Bundle\ChannelBundle\EventListener\ChannelDoctrineListener
    orocrm_channel.event_listener.timezone_change.class:               OroCRM\Bundle\ChannelBundle\EventListener\TimezoneChangeListener

    #twig
    orocrm_channel.twig.metadata_extension.class:                      OroCRM\Bundle\ChannelBundle\Twig\MetadataExtension
    orocrm_channel.twig.lifetime_value_extension.class:                OroCRM\Bundle\ChannelBundle\Twig\LifetimeValueExtension

    #validators
    orocrm_channel.validators.channel_integration_validator.class:     OroCRM\Bundle\ChannelBundle\Validator\ChannelIntegrationConstraintValidator

    # import/export
    orocrm_channel.importexport.helper.channel.class:                  OroCRM\Bundle\ChannelBundle\ImportExport\Helper\ChannelHelper

    # conditions
    oro_workflow.condition.channel_entity_availiable.class:            OroCRM\Bundle\ChannelBundle\Model\Condition\ChannelEntityAvailability

services:
    orocrm_channel.builder.factory:
        class: %orocrm_channel.builder.factory.class%
        arguments:
          - @doctrine
          - @orocrm_channel.provider.settings_provider

    # forms
    orocrm_channel.form.type.channel:
        class: %orocrm_channel.form.type.channel.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
            - @orocrm_channel.form.subscriber.channel_subscriber
        tags:
            - { name: form.type, alias: orocrm_channel_form }

    orocrm_channel.form.type.entity:
        class: %orocrm_channel.form.type.entity.class%
        tags:
            - { name: form.type, alias: orocrm_channel_entities }

    orocrm_channel.form.type.channel_datasource:
        class: %orocrm_channel.form.type.channel_datasource.class%
        arguments:
            - @doctrine
            - %oro_integration.entity.class%
        tags:
            - { name: form.type, alias: orocrm_channel_datasource_form }

    orocrm_channel.form.type.channel_select:
        class: %orocrm_channel.form.type.channel_select.class%
        tags:
            - { name: form.type, alias: orocrm_channel_select_type }

    orocrm_channel.form.type.create_or_select_inline_channel_aware:
        class: %orocrm_channel.form.type.create_or_select_inline_channel_aware.class%
        tags:
            - { name: form.type, alias: oro_entity_create_or_select_inline_channel_aware }

    orocrm_channel.form.type.multiple_entity_channel_aware:
        class: %orocrm_channel.form.type.multiple_entity_channel_aware.class%
        tags:
            - { name: form.type, alias: oro_multiple_entity_channel_aware }

    orocrm_channel.form.channel:
        class:                        Symfony\Component\Form\Form
        factory_method:               createNamed
        factory_service:              form.factory
        arguments:                    ["orocrm_channel_form", "orocrm_channel_form", null]

    # handlers
    orocrm_channel.channel_form.handler:
        class: %orocrm_channel.channel_form.handler.class%
        scope: request
        arguments:
            - @request
            - @orocrm_channel.form.channel
            - @doctrine
            - @event_dispatcher

    orocrm_channel.channel_integration_form.handler:
        class: %orocrm_channel.channel_integration_form.handler.class%
        scope: request
        arguments:
            - @request
            - @form.factory

    # Channel API
    orocrm_channel.channel.manager:
        class: %orocrm_channel.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %orocrm_channel.entity.class%
            - @doctrine.orm.entity_manager

    # Providers
    orocrm_channel.provider.settings_provider:
        class: %orocrm_channel.provider.settings_provider.class%
        arguments:
            - []
            - @orocrm_channel.config_resolver

    orocrm_channel.provider.exclusion_provider:
        class: %orocrm_channel.provider.exclusion_provider.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
            - @orocrm_channel.provider.state_provider
        tags:
            - { name: oro_entity.exclusion_provider.default }

    orocrm_channel.provider.metadata_provider:
        class: %orocrm_channel.provider.entity_metadata.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
            - @oro_entity.entity_provider
            - @oro_entity_config.config_manager
            - @router

    orocrm_channel.provider.request_channel:
        class: %orocrm_channel.provider.request_channel.class%
        arguments:
            - @request
            - @doctrine
        scope: request

    # datagrid
    orocrm_channel.datagrid.extension.orm_channel_limitation:
        class: %orocrm_channel.datagrid.extension.orm_channel_limitation.class%
        tags:
            - { name: oro_datagrid.extension }

    # autocomplete
    orocrm_channel.autocomplete.channel_limitation_handler:
        class: %orocrm_channel.autocomplete.channel_limitation_handler.class%
        calls:
            - [initDoctrinePropertiesByManagerRegistry, ["@doctrine"]]
            - [initSearchIndexer, ["@oro_search.index", %oro_search.entities_config%]]
            - [setAclHelper,["@oro_security.acl_helper"]]

    # config resolver
    orocrm_channel.provider.channel_entity_exclusion_provider:
        class: %orocrm_channel.provider.channel_entity_exclusion_provider.class%
        arguments:
            - @orocrm_channel.provider.settings_provider

    orocrm_channel.provider.channel_entity_provider:
        class: %oro_entity.entity_provider.class%
        parent: oro_entity.entity_provider.abstract
        calls:
            - [setExclusionProvider, [@orocrm_channel.provider.channel_entity_exclusion_provider]]

    orocrm_channel.provider.state_provider:
        class: %orocrm_channel.provider.state_provider.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
            - @orocrm_channel.state_cache
            - @doctrine
            - @oro_security.security_facade.link
            - @oro_security.acl_helper
        tags:
            - { name: kernel.event_listener, event: 'orocrm_channel.channel.save_succeed', method: processChannelChange}
            - { name: kernel.event_listener, event: 'orocrm_channel.channel.delete_succeed', method: processChannelChange}
            - { name: kernel.event_listener, event: 'orocrm_channel.channel.status_change', method: processChannelChange}

    orocrm_channel.provider.utils.entity_state_provider:
        class: %orocrm_channel.provider.utils.entity_state_provider.class%
        abstract: true
        calls:
            - [setStateProvider, [@orocrm_channel.provider.state_provider]]

    orocrm_channel.provider.lifetime.amount_provider:
        class: %orocrm_channel.provider.lifetime.amount_provider.class%
        arguments:
            - @doctrine

    orocrm_channel.provider.lifetime.average_widget_provider:
        class: %orocrm_channel.provider.lifetime.average_widget_provider.class%
        arguments:
            - @doctrine
            - @oro_locale.settings
            - @oro_security.acl_helper

    orocrm_channel.config_resolver:
        class: %orocrm_channel.config_resolver.class%
        arguments:
            - @service_container

    # event listeners
    orocrm_channel.event_listener.navigation:
        class: %orocrm_channel.event_listener.navigation.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
            - @orocrm_channel.provider.state_provider
        tags:
            - { name: kernel.event_listener, event: oro_menu.configure.application_menu, method: onNavigationConfigure }
            - { name: kernel.event_listener, event: oro_menu.configure.shortcuts, method: onNavigationConfigure }

    orocrm_channel.state_cache:
          parent: oro.cache.abstract
          calls:
              - [setNamespace, ['orocrm_channel.state_cache']]

    orocrm_channel.form.subscriber.channel_subscriber:
        class: %orocrm_channel.form.subscriber.channel_subscriber.class%
        arguments:
            - @orocrm_channel.provider.settings_provider

    orocrm_channel.event_listener.channel_change_status:
        class: %orocrm_channel.event_listener.channel_change_status.class%
        arguments:
            - @doctrine
        tags:
            - { name: kernel.event_listener, event: orocrm_channel.channel.status_change, method: onChannelStatusChange }

    orocrm_channel.event_listener.channel_save_succeed:
        class: %orocrm_channel.event_listener.channel_save_succeed.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
            - @doctrine
        tags:
            - { name: kernel.event_listener, event: orocrm_channel.channel.save_succeed, method: onChannelSucceedSave }

    orocrm_channel.event_listener.channel_succeed_deleted:
        class: %orocrm_channel.event_listener.channel_before_deleted.class%
        arguments:
            - @oro_integration.delete_manager
        tags:
            - { name: kernel.event_listener, event: orocrm_channel.channel.before_delete, method: onChannelBeforeDelete }

    orocrm_channel.event_listener.embedded_form:
        class: %orocrm_channel.event_listener.embedded_form.class%
        calls:
            - [setRequest, [@?request=]]
        tags:
            - { name: kernel.event_listener, event: entity_form.render.before, method: addDataChannelField }
            - { name: kernel.event_listener, event: oro_embedded_form.form_submit.before, method: onEmbeddedFormSubmit }

    orocrm_channel.event_listener.doctrine:
      class: %orocrm_channel.event_listener.doctrine.class%
      arguments:
          - @orocrm_channel.provider.settings_provider
      tags:
        - { name: doctrine.event_listener, event: onFlush, method: onFlush }
        - { name: doctrine.event_listener, event: postFlush, method: postFlush }
        - { name: doctrine.event_listener, event: onClear, method: onClear }

    orocrm_channel.event_listener.timezone_change:
      class: %orocrm_channel.event_listener.timezone_change.class%
      arguments:
          - @doctrine
      tags:
        - { name: kernel.event_listener, event: oro_config.update_after, method: onConfigUpdate }

    #twig
    orocrm_channel.twig.metadata_extension:
        class: %orocrm_channel.twig.metadata_extension.class%
        arguments:
            - @orocrm_channel.provider.metadata_provider
            - @orocrm_channel.provider.settings_provider
        tags:
            - { name: twig.extension }

    orocrm_channel.form.integration_type_extension:
        class: %orocrm_channel.form.integration_type_extension.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
        tags:
            - { name: form.type_extension, alias: oro_integration_channel_form }

    orocrm_channel.form.embedded_type_extension:
        class: %orocrm_channel.form.embedded_type_extension.class%
        tags:
            - { name: form.type_extension, alias: embedded_form }

    orocrm_channel.twig.lifetime_value_extension:
        class: %orocrm_channel.twig.lifetime_value_extension.class%
        arguments:
            - @orocrm_channel.provider.lifetime.amount_provider
        tags:
            - { name: twig.extension }

    #validators
    orocrm_channel.validators.channel_integration_validator:
        class: %orocrm_channel.validators.channel_integration_validator.class%
        arguments:
            - @orocrm_channel.provider.settings_provider
        tags:
            - { name: validator.constraint_validator, alias: orocrm_channel.validator.channel_integration }

    # import/export
    orocrm_channel.importexport.helper.channel:
        class: %orocrm_channel.importexport.helper.channel.class%
        arguments:
            - @doctrine

    # conditions
    oro_workflow.condition.custom:
        class: %oro_workflow.condition.channel_entity_availiable.class%
        arguments:
            - @oro_workflow.context_accessor
            - @orocrm_channel.provider.state_provider
        tags:
            - { name: oro_workflow.condition, alias: channel_entity_availiable }
