services:
    oro_channel.builder.factory:
        class: Oro\Bundle\ChannelBundle\Builder\BuilderFactory
        public: true
        arguments:
          - "@doctrine"
          - "@oro_channel.provider.settings_provider"

    oro_channel.form.type.channel:
        class: Oro\Bundle\ChannelBundle\Form\Type\ChannelType
        arguments:
            - "@oro_channel.provider.settings_provider"
            - "@oro_channel.form.subscriber.channel_subscriber"
        tags:
            - { name: form.type, alias: oro_channel_form }

    oro_channel.form.type.entity:
        class: Oro\Bundle\ChannelBundle\Form\Type\ChannelEntityType
        tags:
            - { name: form.type, alias: oro_channel_entities }

    oro_channel.form.type.channel_datasource:
        class: Oro\Bundle\ChannelBundle\Form\Type\ChannelDatasourceType
        arguments:
            - "@doctrine"
            - 'Oro\Bundle\IntegrationBundle\Entity\Channel'
        tags:
            - { name: form.type, alias: oro_channel_datasource_form }

    oro_channel.form.type.channel_select:
        class: Oro\Bundle\ChannelBundle\Form\Type\ChannelSelectType
        arguments:
            - '@oro_channel.provider.channels_by_entities'
        tags:
            - { name: form.type, alias: oro_channel_select_type }

    oro_channel.form.type.create_or_select_inline_channel_aware:
        class: Oro\Bundle\ChannelBundle\Form\Type\CreateOrSelectInlineChannelAwareType
        tags:
            - { name: form.type, alias: oro_entity_create_or_select_inline_channel_aware }

    oro_channel.form.type.multiple_entity_channel_aware:
        class: Oro\Bundle\ChannelBundle\Form\Type\MultipleEntityChannelAwareType
        tags:
            - { name: form.type, alias: oro_multiple_entity_channel_aware }

    oro_channel.form.channel:
        class: Symfony\Component\Form\Form
        factory: ['@form.factory', 'createNamed']
        arguments: ["oro_channel_form", Oro\Bundle\ChannelBundle\Form\Type\ChannelType, null]

    Oro\Bundle\ChannelBundle\Form\Handler\ChannelHandler:
        alias: oro_channel.channel_form.handler

    oro_channel.channel_form.handler:
        class: Oro\Bundle\ChannelBundle\Form\Handler\ChannelHandler
        public: true
        arguments:
            - "@request_stack"
            - "@oro_channel.form.channel"
            - "@doctrine"
            - "@event_dispatcher"

    Oro\Bundle\ChannelBundle\Form\Handler\ChannelIntegrationHandler:
        alias: oro_channel.channel_integration_form.handler

    oro_channel.channel_integration_form.handler:
        class: Oro\Bundle\ChannelBundle\Form\Handler\ChannelIntegrationHandler
        public: true
        arguments:
            - "@request_stack"
            - "@form.factory"

    oro_channel.manager.channel.api:
        class: Oro\Bundle\ChannelBundle\Entity\Manager\ChannelApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ChannelBundle\Entity\Channel'
            - "@doctrine.orm.entity_manager"

    oro_channel.manager.customer_search.api:
        class: Oro\Bundle\ChannelBundle\Entity\Manager\CustomerSearchApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ChannelBundle\Entity\Channel'
            - "@doctrine.orm.entity_manager"
            - "@oro_search.index"
            - "@event_dispatcher"
            - "@oro_channel.provider.settings_provider"

    oro_channel.provider.settings_provider:
        class: Oro\Bundle\ChannelBundle\Provider\SettingsProvider
        public: true
        arguments:
            - '@oro_channel.provider.configuration_provider'

    oro_channel.provider.configuration_provider:
        class: Oro\Bundle\ChannelBundle\Configuration\ChannelConfigurationProvider
        public: false
        parent: oro.static_config_provider.abstract
        arguments:
            - '%kernel.cache_dir%/oro/channels.php'
            - '%kernel.debug%'
            - '@oro_channel.config_resolver'

    oro_channel.provider.metadata_provider:
        class: Oro\Bundle\ChannelBundle\Provider\MetadataProvider
        arguments:
            - "@oro_channel.provider.settings_provider"
            - "@oro_entity.entity_provider"
            - "@oro_entity_config.config_manager"
            - "@router"

    oro_channel.provider.request_channel:
        class: Oro\Bundle\ChannelBundle\Provider\RequestChannelProvider
        arguments:
            - "@request_stack"
            - "@doctrine"

    oro_channel.datagrid.extension.orm_channel_limitation:
        class: Oro\Bundle\ChannelBundle\Datagrid\ChannelLimitationExtension
        tags:
            - { name: oro_datagrid.extension }

    oro_channel.autocomplete.channel_limitation_handler:
        class: Oro\Bundle\ChannelBundle\Autocomplete\ChannelLimitationHandler
        calls:
            - [initDoctrinePropertiesByManagerRegistry, ["@doctrine"]]
            - [initSearchIndexer, ["@oro_search.index", '@oro_search.provider.search_mapping']]
            - [setAclHelper,["@oro_security.acl_helper"]]
            - [setPropertyAccessor, ["@property_accessor"]]

    oro_channel.provider.channel_entity_exclusion_provider:
        class: Oro\Bundle\ChannelBundle\Provider\ChannelEntityExclusionProvider
        arguments:
            - "@oro_channel.provider.settings_provider"

    oro_channel.provider.channel_entity_provider:
        class: Oro\Bundle\EntityBundle\Provider\EntityProvider
        parent: oro_entity.entity_provider.abstract
        lazy: true
        calls:
            - [setExclusionProvider,  ["@oro_channel.provider.channel_entity_exclusion_provider"]]

    oro_channel.provider.state_provider:
        class: Oro\Bundle\ChannelBundle\Provider\StateProvider
        arguments:
            - "@oro_channel.provider.settings_provider"
            - "@oro_channel.state_cache"
            - "@doctrine"
            - "@oro_channel.state_provider.token_accessor"

    oro_channel.state_provider.token_accessor:
        class: Oro\Bundle\SecurityBundle\Authentication\TokenAccessor
        public: false
        arguments:
            - '@security.token_storage'

    oro_channel.provider.utils.entity_state_provider:
        class: Oro\Bundle\ChannelBundle\Provider\Utility\EntityStateProvider
        abstract: true
        calls:
            - [setStateProvider,  ["@oro_channel.provider.state_provider"]]

    oro_channel.provider.lifetime.amount_provider:
        class: Oro\Bundle\ChannelBundle\Provider\Lifetime\AmountProvider
        public: true
        arguments:
            - "@doctrine"

    oro_channel.provider.lifetime.average_widget_provider:
        class: Oro\Bundle\ChannelBundle\Provider\Lifetime\AverageLifetimeWidgetProvider
        arguments:
            - '@doctrine'
            - '@oro_locale.settings'
            - '@oro_security.acl_helper'
            - '@oro_dashboard.filter.date_filter_processor'

    Oro\Bundle\ChannelBundle\Provider\Lifetime\AverageLifetimeWidgetProvider:
        alias: oro_channel.provider.lifetime.average_widget_provider

    oro_channel.config_resolver:
        class: Oro\Component\Config\Resolver\SystemAwareResolver
        arguments:
            - "@service_container"

    oro_channel.event_listener.navigation:
        class: Oro\Bundle\ChannelBundle\EventListener\NavigationListener
        arguments:
            - "@oro_channel.provider.settings_provider"
            - "@oro_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 }
            - { name: kernel.event_listener, event: oro_channel.channel.save_succeed, method: onChannelSave }

    oro_channel.state_cache:
          parent: oro.data.cache
          tags:
              - { name: 'cache.pool', namespace: 'oro_channel_state' }

    oro_channel.form.subscriber.channel_subscriber:
        class: Oro\Bundle\ChannelBundle\Form\EventListener\ChannelTypeSubscriber
        public: false
        arguments:
            - "@oro_channel.provider.settings_provider"

    oro_channel.event_listener.update_integration_connectors:
        class: Oro\Bundle\ChannelBundle\EventListener\UpdateIntegrationConnectorsListener
        arguments:
            - "@oro_channel.provider.settings_provider"
            - "@doctrine"
        tags:
            - { name: kernel.event_listener, event: oro_channel.channel.save_succeed, method: onChannelSave }

    oro_channel.event_listener.channel_succeed_deleted:
        class: Oro\Bundle\ChannelBundle\EventListener\ChannelBeforeDeleteListener
        arguments:
            - "@oro_integration.delete_manager"
        tags:
            - { name: kernel.event_listener, event: oro_channel.channel.before_delete, method: onChannelBeforeDelete }

    oro_channel.event_listener.embedded_form:
        class: Oro\Bundle\ChannelBundle\EventListener\EmbeddedFormListener
        arguments:
            - '@request_stack'
        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 }

    oro_channel.event_listener.doctrine:
      class: Oro\Bundle\ChannelBundle\EventListener\ChannelDoctrineListener
      arguments:
          - '@oro_channel.provider.settings_provider'
          - '@oro_channel.manager.lifetime_history_status_update'
      tags:
        - { name: doctrine.event_listener, event: onFlush }
        - { name: doctrine.event_listener, event: postFlush }

    oro_channel.event_listener.refresh_channel_cache_listener:
          class: Oro\Bundle\ChannelBundle\EventListener\ORM\RefreshChannelCacheListener
          arguments:
              - '@oro_channel.provider.state_provider'
          tags:
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\ChannelBundle\Entity\Channel', event: prePersist }
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\ChannelBundle\Entity\Channel', event: postRemove }

    oro_channel.event_listener.timezone_change:
      class: Oro\Bundle\ChannelBundle\EventListener\TimezoneChangeListener
      arguments:
          - "@oro_message_queue.message_producer"
      tags:
        - { name: kernel.event_listener, event: oro_config.update_after, method: onConfigUpdate }

    oro_channel.event_listener.job_execution:
        class: Oro\Bundle\ChannelBundle\EventListener\JobExecutionSubscriber
        arguments:
            - "@oro_entity.doctrine_helper"
            - "@security.token_storage"
        tags:
            - { name: kernel.event_subscriber }

    oro_channel.twig.channel_extension:
        class: Oro\Bundle\ChannelBundle\Twig\ChannelExtension
        public: false
        arguments:
            - "@oro_platform.twig.service_locator"
        tags:
            - { name: twig.extension }

    oro_channel.form.integration_type_extension:
        class: Oro\Bundle\ChannelBundle\Form\Extension\IntegrationTypeExtension
        arguments:
            - "@oro_channel.provider.settings_provider"
        tags:
            - { name: form.type_extension, extended_type: Oro\Bundle\IntegrationBundle\Form\Type\ChannelType, alias: oro_integration_channel_form }

    oro_channel.form.embedded_type_extension:
        class: Oro\Bundle\ChannelBundle\Form\Extension\EmbeddedFormTypeExtension
        tags:
            - { name: form.type_extension, alias: embedded_form, extended_type: Oro\Bundle\EmbeddedFormBundle\Form\Type\EmbeddedFormType }

    oro_channel.validators.channel_integration_validator:
        class: Oro\Bundle\ChannelBundle\Validator\ChannelIntegrationConstraintValidator
        arguments:
            - "@oro_channel.provider.settings_provider"
        tags:
            - { name: validator.constraint_validator, alias: oro_channel.validator.channel_integration }

    oro_channel.importexport.template_fixture.channel:
        class: Oro\Bundle\ChannelBundle\ImportExport\TemplateFixture\ChannelFixture
        tags:
            - { name: oro_importexport.template_fixture }

    oro_channel.importexport.helper.channel:
        class: Oro\Bundle\ChannelBundle\ImportExport\Helper\ChannelHelper
        arguments:
            - "@doctrine"

    oro_workflow.condition.custom:
        class: Oro\Bundle\ChannelBundle\Model\Condition\ChannelEntityAvailability
        arguments:
            - "@oro_channel.provider.state_provider"
        tags:
            - { name: oro_action.condition, alias: channel_entity_availiable }

    oro_channel.provider.channels_by_entities:
        class: Oro\Bundle\ChannelBundle\Provider\ChannelsByEntitiesProvider
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_security.acl_helper'

    oro_channel.form.extension.single_channel_mode:
        class: Oro\Bundle\ChannelBundle\Form\Extension\SingleChannelModeExtension
        arguments:
            - '@oro_channel.provider.channels_by_entities'
        tags:
            - { name: form.type_extension, alias: oro_channel_select_type, extended_type: Oro\Bundle\ChannelBundle\Form\Type\ChannelSelectType }

    oro_channel.event_listener.transitions_attribute:
        class: Oro\Bundle\ChannelBundle\EventListener\TransitionsAttributeListener
        arguments:
            - '@form.factory'
            - '@oro_action.expression.context_accessor'
        tags:
            - { name: kernel.event_listener, event: oro_workflow.transitions.attribute.before_add, method: beforeAddAttribute }

    oro_channel.security.acl.voter.channel:
        class: Oro\Bundle\ChannelBundle\Acl\Voter\ChannelVoter
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@Psr\Container\ContainerInterface'
        calls:
            - [setClassName, ['Oro\Bundle\ChannelBundle\Entity\Channel']]
        tags:
            - { name: security.voter, priority: 500 }
            - { name: container.service_subscriber, id: oro_channel.provider.settings_provider }

    oro_channel.account_lifetime_listener:
        class: Oro\Bundle\ChannelBundle\EventListener\AccountLifetimeListener
        arguments:
            - '@Psr\Container\ContainerInterface'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }
            - { name: doctrine.event_listener, event: onClear }
            - { name: container.service_subscriber, id: oro_currency.query.currency_transformer }
            - { name: container.service_subscriber, id: oro_sales.manager.account_customer }
            - { name: container.service_subscriber, id: oro_channel.manager.lifetime_history_status_update }

    oro_channel.manager.lifetime_history_status_update:
        class: Oro\Bundle\ChannelBundle\Entity\Manager\LifetimeHistoryStatusUpdateManager
        arguments:
            - '@doctrine'
            - '@oro_message_queue.client.message_producer'

    oro_channel.event_listener.lifetime_history_demo_data_fixtures:
        class: Oro\Bundle\ChannelBundle\EventListener\LifetimeHistoryDataFixturesListener
        arguments:
            - '@oro_channel.manager.lifetime_history_status_update'
        tags:
            - { name: kernel.event_listener, event: oro_migration.data_fixtures.pre_load, method: onPreLoad }

