parameters:
    oro_analytics.model.analytics_aware_interface: Oro\Bundle\AnalyticsBundle\Model\AnalyticsAwareInterface
    oro_analytics.model.rfm_aware_interface: Oro\Bundle\AnalyticsBundle\Model\RFMAwareInterface
services:
    oro_analytics.builder:
        class: Oro\Bundle\AnalyticsBundle\Builder\AnalyticsBuilder
        arguments:
            - !tagged_iterator oro_analytics.builder

    oro_analytics.builder.rfm:
        class: Oro\Bundle\AnalyticsBundle\Builder\RFMBuilder
        arguments:
            - !tagged_iterator oro_analytics.builder.rfm
            - '@oro_entity.doctrine_helper'
        tags:
            - { name: oro_analytics.builder }

    oro_analytics.form.type.category:
        class: Oro\Bundle\AnalyticsBundle\Form\Type\RFMCategoryType
        tags:
            - { name: form.type, alias: "oro_analytics_rfm_category" }

    oro_analytics.form.type.category_settings:
        class: Oro\Bundle\AnalyticsBundle\Form\Type\RFMCategorySettingsType
        tags:
            - { name: form.type, alias: "oro_analytics_rfm_category_settings" }

    oro_analytics.form.channel_type_extension:
        class: Oro\Bundle\AnalyticsBundle\Form\Extension\ChannelTypeExtension
        arguments:
            - '@oro_entity.doctrine_helper'
            - '%oro_analytics.model.rfm_aware_interface%'
            - 'Oro\Bundle\AnalyticsBundle\Entity\RFMMetricCategory'
        tags:
            - { name: form.type_extension, alias: oro_channel_form, extended_type: Oro\Bundle\ChannelBundle\Form\Type\ChannelType }

    oro_analytics.placeholder.rfm_filter:
        class: Oro\Bundle\AnalyticsBundle\Placeholder\RFMAwareFilter
        public: true
        arguments:
            - '%oro_analytics.model.analytics_aware_interface%'

    oro_analytics.event_listener.timezone_change:
        class: Oro\Bundle\AnalyticsBundle\EventListener\TimezoneChangeListener
        arguments:
            - '@oro_analytics.model.rfm_state_manager'
            - '@oro_analytics.calculate_analytics_scheduler'
        tags:
            - { name: kernel.event_listener, event: oro_config.update_after, method: onConfigUpdate }

    oro_analytics.validator.categories:
        class: Oro\Bundle\AnalyticsBundle\Validator\CategoriesValidator
        tags:
            - { name: validator.constraint_validator, alias: oro_analytics.categories_validator }

    oro_analytics.model.rfm_state_manager:
        class: Oro\Bundle\AnalyticsBundle\Model\RFMMetricStateManager
        arguments:
            - '@oro_entity.doctrine_helper'
            - '%oro_analytics.model.rfm_aware_interface%'
            - 'Oro\Bundle\ChannelBundle\Entity\Channel'

    oro_analytics.event_listener.rfm_category:
        class: Oro\Bundle\AnalyticsBundle\EventListener\RFMCategoryListener
        arguments:
            - '@oro_analytics.model.rfm_state_manager'
            - '@oro_analytics.calculate_analytics_scheduler'
            - 'Oro\Bundle\AnalyticsBundle\Entity\RFMMetricCategory'
            - 'Oro\Bundle\ChannelBundle\Entity\Channel'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: kernel.event_listener, event: oro_channel.channel.save_succeed, method: onChannelSucceedSave }

    oro_analytics.calculate_analytics_scheduler:
        class: Oro\Bundle\AnalyticsBundle\Service\CalculateAnalyticsScheduler
        public: true
        arguments:
            - '@oro_message_queue.message_producer'
