services:
    oro_featuretoggle.expression.feature_enabled:
        class: Oro\Bundle\FeatureToggleBundle\ConfigExpression\FeatureEnabled
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: oro_action.condition, alias: feature_enabled }

    oro_featuretoggle.expression.feature_resource_enabled:
        class: Oro\Bundle\FeatureToggleBundle\ConfigExpression\FeatureResourceEnabled
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: oro_action.condition, alias: feature_resource_enabled }

    oro_featuretoggle.configuration.provider:
        class: Oro\Bundle\FeatureToggleBundle\Configuration\ConfigurationProvider
        parent: oro.static_config_provider.abstract
        arguments:
            - '%kernel.cache_dir%/oro/features.php'
            - '%kernel.debug%'
            - '@oro_featuretoggle.configuration'
            - '@oro_featuretoggle.configuration_extension'

    oro_featuretoggle.configuration.manager:
        class: Oro\Bundle\FeatureToggleBundle\Configuration\ConfigurationManager
        public: true
        arguments:
            - '@oro_featuretoggle.configuration.provider'

    oro_featuretoggle.configuration:
        class: Oro\Bundle\FeatureToggleBundle\Configuration\FeatureToggleConfiguration
        arguments:
            - '@oro_featuretoggle.configuration_extension'

    oro_featuretoggle.configuration_extension:
        class: Oro\Bundle\FeatureToggleBundle\Configuration\ConfigurationExtension
        arguments:
            - !tagged_iterator oro_feature.config_extension

    oro_featuretoggle.twig.feature_extension:
        class: Oro\Bundle\FeatureToggleBundle\Twig\FeatureExtension
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_featuretoggle.checker.feature_checker:
        class: Oro\Bundle\FeatureToggleBundle\Checker\FeatureChecker
        public: true
        arguments:
            - '@oro_featuretoggle.feature_decision_manager'
            - '@oro_featuretoggle.feature_resource_decision_manager'
            - '@oro_featuretoggle.configuration.manager'

    Oro\Bundle\FeatureToggleBundle\Checker\FeatureChecker:
        alias: oro_featuretoggle.checker.feature_checker

    oro_featuretoggle.feature_decision_manager:
        class: Oro\Bundle\FeatureToggleBundle\Checker\FeatureDecisionManager
        arguments:
            - '@oro_featuretoggle.configuration.manager'
            - !abstract '$voters defined in Oro\Bundle\FeatureToggleBundle\DependencyInjection\CompilerPass\FeatureToggleVotersPass'
            - !abstract '$strategy defined in Oro\Bundle\FeatureToggleBundle\DependencyInjection\OroFeatureToggleExtension'
            - !abstract '$allowIfAllAbstainDecisions defined in Oro\Bundle\FeatureToggleBundle\DependencyInjection\OroFeatureToggleExtension'
            - !abstract '$allowIfEqualGrantedDeniedDecisions defined in Oro\Bundle\FeatureToggleBundle\DependencyInjection\OroFeatureToggleExtension'

    oro_featuretoggle.feature_resource_decision_manager:
        class: Oro\Bundle\FeatureToggleBundle\Checker\FeatureResourceDecisionManager
        arguments:
            - '@oro_featuretoggle.feature_decision_manager'
            - '@oro_featuretoggle.configuration.manager'

    oro_featuretoggle.layout.data_provider.feature_provider:
        class: Oro\Bundle\FeatureToggleBundle\Layout\DataProvider\FeatureProvider
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: layout.data_provider, alias: feature }

    oro_featuretoggle.voter.config_voter:
        class: Oro\Bundle\FeatureToggleBundle\Checker\Voter\ConfigVoter
        arguments:
            - '@oro_config.manager'
            - '@oro_featuretoggle.configuration.manager'
        tags:
            - { name: oro_featuretogle.voter }

    oro_featuretoggle.voter.dependency_voter:
        class: Oro\Bundle\FeatureToggleBundle\Checker\Voter\DependencyVoter
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
            - '@oro_featuretoggle.configuration.manager'
        tags:
            - { name: oro_featuretogle.voter }

    oro_featuretoggle.event_listener.request:
        class: Oro\Bundle\FeatureToggleBundle\EventListener\RequestListener
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onRequest }

    oro_featuretoggle.event_listener.system_config:
        class: Oro\Bundle\FeatureToggleBundle\EventListener\ConfigListener
        arguments:
            - '@event_dispatcher'
            - '@oro_featuretoggle.configuration.manager'
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: kernel.event_listener, event: oro_config.settings_before_save, method: onSettingsSaveBefore }
            - { name: kernel.event_listener, event: oro_config.update_after, method: onUpdateAfter }
            - { name: kernel.event_listener, event: oro_config.config_manager_scope_id_change, method: onScopeIdChange }

    oro_featuretoggle.event_listener.feature_checker_aware_command:
        class: Oro\Bundle\FeatureToggleBundle\EventListener\FeatureCheckerAwareCommandListener
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: kernel.event_listener, event: console.command, method: onConsoleCommand}

    oro_featuretoggle.event_listener.console_command:
        class: Oro\Bundle\FeatureToggleBundle\EventListener\ConsoleCommandListener
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: kernel.event_listener, event: console.command, method: onConsoleCommand}

    oro_featuretoggle.menu.feature_extension:
        class: Oro\Bundle\FeatureToggleBundle\Menu\FeatureAwareMenuFactoryExtension
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: oro_navigation.menu_extension, priority: 90 }

    oro_featuretoggle.async.message_filter:
        class: Oro\Bundle\FeatureToggleBundle\Async\MessageFilter
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
        tags:
            - { name: oro_message_queue.message_filter }

    oro_featuretoggle.event_listener.cache_state:
        class: Oro\Bundle\FeatureToggleBundle\EventListener\CacheStateChangeListener
        arguments:
            - '@oro_message_queue.consumption.cache_state'
        tags:
            - { name: kernel.event_listener, event: oro_featuretoggle.features.change, method: onFeaturesChange }
