services:
    Oro\Bundle\ActivityBundle\Manager\ActivityManager:
        alias: oro_activity.manager

    oro_activity.manager:
        class: Oro\Bundle\ActivityBundle\Manager\ActivityManager
        public: true
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_entity.orm.entity_class_resolver'
            - '@oro_entity_config.provider.activity'
            - '@oro_entity_config.provider.grouping'
            - '@oro_entity_config.provider.entity'
            - '@oro_entity_config.provider.extend'
            - '@oro_entity_extend.association_manager'
            - '@oro_featuretoggle.checker.feature_checker'
        calls:
            - [setEventDispatcher, ['@event_dispatcher']]

    oro_activity.association_helper:
        class: Oro\Bundle\ActivityBundle\Tools\ActivityAssociationHelper
        public: false
        arguments:
            - '@oro_entity_config.config_manager'

    oro_activity.entity_config_dumper.extension:
        class: Oro\Bundle\ActivityBundle\Tools\ActivityEntityConfigDumperExtension
        parent: oro_entity_extend.entity_config_dumper.extension.association
        tags:
            - { name: oro_entity_extend.entity_config_dumper_extension }

    oro_activity.migration.extension.activity:
        class: Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension
        tags:
            - { name: oro_migration.extension, extension_name: activity }

    Oro\Bundle\UIBundle\Provider\ChainWidgetProvider:
        alias: oro_activity.widget_provider.activities

    oro_activity.widget_provider.activities:
        class: Oro\Bundle\UIBundle\Provider\ChainWidgetProvider
        public: true
        arguments:
            - [] # providers

    oro_activity.widget_provider.activities.main:
        class: Oro\Bundle\ActivityBundle\Provider\ActivityWidgetProvider
        arguments:
            - '@oro_activity.manager'
            - '@security.authorization_checker'
            - '@translator'
            - '@oro_entity.entity_identifier_accessor'
            - '@oro_entity.routing_helper'
        tags:
            - { name: oro_activity.activity_widget_provider }

    oro_activity.listener.context_grid:
        class: Oro\Bundle\ActivityBundle\EventListener\Datagrid\ContextGridListener
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_entity.entity_class_name_helper'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after, method: onBuildAfter }

    oro_activity.widget_provider.actions:
        class: Oro\Bundle\ActivityBundle\Provider\ActivityActionWidgetProvider
        arguments:
            - '@oro_activity.manager'
            - '@oro_ui.placeholder.provider'
        tags:
            - { name: oro_ui.view_action_provider, group: activity }
            - { name: oro_ui.update_action_provider, group: activity }

    oro_activity.routing.options_resolver.activity_association:
        class: Oro\Bundle\ActivityBundle\Routing\ActivityAssociationRouteOptionsResolver
        public: false
        arguments:
            - '@oro_entity_config.provider.grouping'
            - '@oro_entity.entity_alias_resolver'
        tags:
            - { name: oro.api.routing_options_resolver, view: default }

    oro_activity.exclusion_provider:
        class: Oro\Bundle\ActivityBundle\Provider\ActivityExclusionProvider
        public: false
        arguments:
            - '@oro_entity_config.config_manager'
        tags:
            - { name: oro_entity.exclusion_provider.api }

    oro_activity.manager.activity.api:
        class: Oro\Bundle\ActivityBundle\Entity\Manager\ActivityApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'

    oro_activity.manager.activity_entity.api:
        class: Oro\Bundle\ActivityBundle\Entity\Manager\ActivityEntityApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'

    oro_activity.manager.activity_search.api:
        class: Oro\Bundle\ActivityBundle\Entity\Manager\ActivitySearchApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'
            - '@oro_search.index'

    oro_activity.activity_entity_delete_handler.proxy:
        class: Oro\Bundle\ActivityBundle\Handler\ActivityEntityDeleteHandlerProxy
        public: true
        arguments:
            - '@oro_activity.activity_entity_delete_handler'

    oro_activity.activity_entity_delete_handler:
        class: Oro\Bundle\ActivityBundle\Handler\ActivityEntityDeleteHandler
        arguments:
            - '@doctrine'
            - '@oro_activity.manager'
            - '@oro_activity.activity_entity_delete_handler_extension'

    oro_activity.activity_entity_delete_handler_extension:
        class: Oro\Bundle\ActivityBundle\Handler\ActivityEntityDeleteHandlerExtension
        arguments:
            - '@security.authorization_checker'
            - '@oro_entity.delete_handler_access_denied_exception_factory'

    Oro\Bundle\ActivityBundle\Autocomplete\ContextSearchHandler:
        alias: oro_activity.form.handler.autocomplete

    oro_activity.form.handler.autocomplete:
        class: Oro\Bundle\ActivityBundle\Autocomplete\ContextSearchHandler
        public: true
        arguments:
            - '@translator'
            - '@oro_search.index'
            - '@oro_activity.manager'
            - '@oro_entity_config.config_manager'
            - '@oro_entity.entity_class_name_helper'
            - '@doctrine.orm.entity_manager'
            - '@oro_entity.entity_name_resolver'
            - '@event_dispatcher'

    oro_activity.form.handler.activity_entity.api:
        class: Oro\Bundle\ActivityBundle\Form\Handler\ActivityEntityApiHandler
        public: true
        arguments:
            - '@oro_activity.form.activity_entity.api'
            - '@request_stack'
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'
            - '@security.authorization_checker'

    oro_activity.form.activity_entity.api:
        class: Symfony\Component\Form\Form
        factory: ['@form.factory', createNamed]
        arguments:
            - targets
            - Oro\Bundle\FormBundle\Form\Type\RelatedEntityStandaloneCollectionApiType
            - ~
            - constraints:
                - Count:
                    min: 1
                    minMessage: "The 'targets' collection should contain at least one element"

    oro_activity.manager.activity_target.api:
        class: Oro\Bundle\ActivityBundle\Entity\Manager\ActivityTargetApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'

    oro_activity.manager.activity_context.api:
        class: Oro\Bundle\ActivityBundle\Entity\Manager\ActivityContextApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_entity_config.config_manager'
            - '@router'
            - '@oro_entity.entity_alias_resolver'
            - '@oro_entity.entity_name_resolver'
            - '@oro_featuretoggle.checker.feature_checker'
            - '@security.authorization_checker'

    oro_activity.grid.contexts_extension:
        class: Oro\Bundle\ActivityBundle\Grid\Extension\ContextsExtension
        arguments:
            - '@oro_entity.orm.entity_class_resolver'
            - '@oro_activity.manager'
            - '@oro_entity_config.provider.entity'
            - '@router'
        tags:
            - { name: oro_datagrid.extension }

    Oro\Bundle\ActivityBundle\EntityConfig\ActivityEntityConfiguration:
        tags:
            - oro_entity_config.validation.entity_config

    Oro\Bundle\ActivityBundle\EntityConfig\GridEntityConfiguration:
        tags:
            - oro_entity_config.validation.entity_config
